I have a dispatch_async call to a secondary thread and just for testing purposes I wanted to sleep the secondary thread for 5 seconds. Here is the code:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
sleep(5);
});
When I test this on Mac OSX Lion 10.7.2, the sleep() function does not put the thread to sleep. And on the iPhone simulator using same code it does.
On the mac, sleep works on the main thread, and on the secondary thread using [NSThread sleepUntilTimeInterval:] works too.
Why won't the sleep() function work on secondary threads on the mac? Thank you.