I get some doubts about behavior of this code :
dispatch_async(queue, ^{
sleep(2);
NSLog(@"step1");
dispatch_sync(queue, ^{
sleep(3);
NSLog(@"step 2");
});
NSLog(@"step 3");
});
From these rows i expected to get as output step1 -> step3 -> step2 but i obtain only step1.
If i change dispatch_sync with dispatch_async it works as expected, Does dispatch_sync into a dispatch_async call create this kind of problem ?
Edit after answers ----------------
This case create a deadlock:
You can check accepted answer to have explanation of this situation and check this link for documentation http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/dispatch_async.3.html