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?

JeffP
  • 187
  • 1
  • 7

1 Answers1

1

Yes. In the normal case, that's exactly what will happen.

If you want to wait for something to complete before continuing, research DispatchGroup.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610