Using this as a frame of reference, is there any reason why the following example {could not} / {would not} result in the GCD Thread Pool running exclusively on the main thread?
int main()
{
dispatch_queue_t myQueue = dispatch_queue_create("myQ",NULL); // create serial queue
//
dispatch_sync(myQueue, ^{/*some simple block*/});
....
dispatch_sync(myQueue, ^{/*some simple block*/});
}
My understanding is that GCD would try to optimize performance where possible, handing the blocks off (when beneficial) to any available thread. However monitoring this in xcode reveals that this may be running exclusively on the main thread. It is not until the dispatch calls become async
that a second thread is utilized.
I would just like to understand when/why a second thread may or may not be called. Previous to this I would assume that a second thread would always be called.