Suppose I call dispatch_async()
three times in order:
dispatch_async(dispatch_get_main_queue(),
^{
[self doOne];
});
// some code here
dispatch_async(dispatch_get_main_queue(),
^{
[self doTwo];
});
// more code here
dispatch_async(dispatch_get_main_queue(),
^{
[self doThree];
});
Will this always be executed like
[self doOne]
, [self doTwo]
, then [self doThree]
, or is the order is guaranteed?
In this case, the question probably is if the main queue is serial or concurrent.
From the documentation:
dispatch_get_main_queue
Returns the serial dispatch queue associated with the application’s main thread.
so the main queue is a serial queue, and [self doOne]
, [self doTwo]
, [self doThree]
are executed sequentially in that order.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With