Mahesh
Mahesh

Reputation: 662

Pausing particular thread in iOS?

in my iPhone 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?

Upvotes: 1

Views: 1236

Answers (2)

Inder Kumar Rathore
Inder Kumar Rathore

Reputation: 39978

Yeah this is absolutely right. This will pause the current thread on which you are calling [NSThread sleepForTimeInterval:]

Upvotes: 1

Alfonso
Alfonso

Reputation: 8482

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.

Upvotes: 2

Related Questions