0

Serial dispatch queues will execute their tasks one at a time. But what if I have task1 and task2 in the queue. task1 one starts execution and calls a function with a completion block (which I assume will use a different thread to execute). At this point, I believe task1 will exit, even though the completion block has not yet been called. Is it a possibility that task2 will start executing before the completion block from task 1 is executed?

4

1 回答 1

1

是的。在正常情况下,这正是会发生的事情。

如果您想等待某事完成后再继续,请研究DispatchGroup

于 2018-11-27T21:28:28.380 回答