Timer and Touch Event concurrent issue
Hi All,
I heard there is no multi-thread thing on iPhone, not sure how Touch Event and Timer work this out. I mean would Touch Event interrupt Timer thread?
For example:
Timer{ i++; }
TouchEnded{i--;}
So if timer never get interrupted by Touch Event, then i don't need to worry about anything, otherwise how to syncronize "i"?
I heard there is no multi-thread thing on iPhone, not sure how Touch Event and Timer work this out. I mean would Touch Event interrupt Timer thread?
For example:
Timer{ i++; }
TouchEnded{i--;}
So if timer never get interrupted by Touch Event, then i don't need to worry about anything, otherwise how to syncronize "i"?
claudie Wrote:I heard there is no multi-thread thing on iPhone
"multi-thread thing" could mean a number of different things, but the iPhone certainly lets you do preemptive multithreading.
So is there any way to prevent NSTimer to get interrupted by touch event? I mean always let NSTimer to finish its work before processing touch event?
An NSTimer runs on a given thread, usually the main thread, unless specifically told otherwise. Events do, too. So, no, there is no preemption.
Thanks guys. I did test myself, NSTimer and Event all handled by one thread(main thread), there is no multiple threading here. So there is no need to worry about concurrent. And after 7 hours debugging, i found out my bug is related to the way how i implement double link list, which made me thinking it was concurrent issue.
7 hours debugging!!! For you guys, it probably only need 7 mins, girls shouldn't do coding. Sign.
7 hours debugging!!! For you guys, it probably only need 7 mins, girls shouldn't do coding. Sign.
claudie Wrote:7 hours debugging!!! For you guys, it probably only need 7 mins, girls shouldn't do coding.
If you put in 7 hours of debugging on something, then either it was an assignment (ie. job or homework) or you REALLY want to code. Either way, you're going to code.
Measure twice, cut once, curse three or four times.
If you want to use the normal setup(ie not do your own timing code) let the timer call your main loop. After your loop finishes it checks for touch events. It all can happen on one thread.
Actually i was debugging for my boyfriend, he just throw this shit code to me ask me to find out what's wrong, and in the end it turns out he doesn't even know how to write a double linked list, how shit he is, i'm gonna dump him!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Timer Slows down in sleep mode | chrism | 13 | 5,205 |
Jun 14, 2009 05:36 PM Last Post: longjumper |
|
| iphone watchdog timer | macnib | 5 | 3,570 |
May 10, 2009 10:58 PM Last Post: kodex |
|
| UIScrollView pausing timer when scrolling | duncster | 1 | 2,556 |
Jan 14, 2009 01:00 PM Last Post: duncster |
|
| UIWebView touch event | wonza | 1 | 4,302 |
Dec 2, 2008 06:58 AM Last Post: godexsoft |
|

