concurrency - iOS GCD custom concurrent queue execution sequence -


i have question regarding issue , according apple's documents

concurrent concurrent queues (also known type of global dispatch queue) execute 1 or more tasks concurrently, but tasks still started in order in added queue. executing tasks run on distinct threads managed dispatch queue. exact number of tasks executing @ given point variable , depends on system conditions. in ios 5 , later, can create concurrent dispatch queues specifying dispatch_queue_concurrent queue type. in addition, there 4 predefined global concurrent queues application use. more information on how global concurrent queues, see getting global concurrent dispatch queues.

and test, using sample code ,

  dispatch_queue_t concurrentqueue;     concurrentqueue = dispatch_queue_create("com.gcd.concurrentqueue",                                                  dispatch_queue_concurrent);      dispatch_async(concurrentqueue, ^{          nslog(@"first job ");     });     dispatch_async(concurrentqueue, ^{         nslog(@"second job");     });      dispatch_async(concurrentqueue, ^{         nslog(@"third job ");   }); 

but results seems not order in added, here results,

2015-06-03 18:36:38.114 googlypuff[58461:1110680] first job  2015-06-03 18:36:38.114 googlypuff[58461:1110682] third job 2015-06-03 18:36:38.114 googlypuff[58461:1110679] second job 

so question , shouldn't first, second , third ?

any advice welcome , , help.

"concurrent" means run @ same time , no assumptions should made in progress of them @ given moment , finish first. whole meaning , implication of concurrency: between 1 line of code , next in 1 concurrent operation - during 1 line of code - else other concurrent operation might happening.

so, in answer particular question, these tasks may have started in known order, happened quickly, , after point progress interleaved unpredictably. , nslog calls part of progress; not, , cannot, tell when tasks started!


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -