in my iPhone 开发者_StackOverflow中文版app, I have used 2 threads. Both functions differently in different class. On particular condition I want to pause particular thread so I have used
[NSThread sleepForTimeInterval:]
So my question is am I doing right or this sleep causes sleep in whole application? If yes what is other alternative?If you want to pause your thread for a given amount of time, then [NSThread sleepForTimeInterval:]
is just fine. However if you want to wait for a given event to occur (e.g. wait for another thread to catch up) you should take a look at the NSCondition
class.
Yeah this is absolutely right. This will pause the current thread on which you are calling [NSThread sleepForTimeInterval:]
精彩评论