I was reading through this great tutorial when I came accross the following line (as background: we were learning how to use dispatch_apply
to replace a for
loop and concurrently download photos):
Be aware that although you have code that will add the photos in a thread safe manner, the ordering of the images could be different depending on which thread finishes first.
This line really threw me off for some reason. I thought dispatch_apply
will run a task on one concurrent thread, GlobalUserInitiatedQueue
, not multiple different threads. He calls the method by saying:
dispatch_apply(addresses.count, GlobalUserInitiatedQueue) {
So is GlobalUserInitiatedQueue
one thread, multiple threads, and what's the difference between a thread and a queue? From what it seems, they're used analogously. Does that mean a concurrent queue has multiple threads running at the same time?
Thanks -
From the guide:
It can't be clearer than that. Multiple threads, start in the order of the tasks on the queue but finishing in no specific order.
I love tutorials and material that is aim to explains stuff in great details. However, when in doubts, I always go back to the Apple official documentations.