- When any custom dispatch queue (serial or concurrent) is created on which thread do they execute tasks.
GCD creates “worker threads”, places them in a “pool”, and it draws upon that pool as threads are needed. Bottom line, GCD takes care of all of the thread-related stuff for you and you need not worry about that.
- I am a bit confused by below text from GCD documentation here:
In addition to any custom queues you create, the system automatically creates a serial queue and binds it to your application’s main thread. For more information about getting the queue for the main thread, see Getting Common Queues at Runtime.
It’s just saying that GCD creates the main
queue for you, binding it to the app’s main thread. Since everything we do in GCD is with queues, we need a queue bound to the main thread so that we can use standard GCD patterns to dispatch to it.
- What happens if
dispatch_suspend()
or dispatch_resume()
is called on global queue?
As the documentation says, they have no effect:
Calls to the suspend()
, resume()
, and dispatch_set_context(_:_:)
functions have no effect on the returned queues.
You can’t use barriers on global queues, either.