3
我想了解隊列類型之間的差異。 據我瞭解有3種類型:GCD隊列類型
- 全球隊列 - 並行 - 因爲他們提交
- 私人塊被執行 - 串行 - 塊儘快不管爲了
- 主隊列執行隊列 - 串行
我想知道的是: 當提交給每種隊列時,dispatch_sync和dispatch_async之間有什麼區別? 這是我的理解它迄今:
dispatch_sync(global_queue)^
{
// blocks are executed one after the other in no particular order
// example: block 3 executes. when it finishes block 7 executes.
}
dispatch_async(global_queue)^
{
// blocks are executed concurrently in no particular order
// example: blocks 2,4,5,7 execute at the same time.
}
dispatch_sync(main_queue)^
{
// blocks are executed one after the other in the order they were submitted
// example: block 1 executes. when it finishes block 2 will execute and so forth.
}
dispatch_async(main_queue)^
{
// blocks are executed concurrently in the order they were submitted
// example: blocks 1-4 (or whatever amount of threads the system can handle at one time) will fire at the same time.
// when the first block completes block 5 will then execute.
}
我想知道我的這種看法有多少是正確的。