GCD队列优先级简介

2016-05-04  本文已影响400人  Django_Monstar

//声明一个串行队列 优先级low

dispatch_queue_t serialQueue=

dispatch_queue_create("serial_queue",DISPATCH_QUEUE_SERIAL);

dispatch_set_target_queue(serialQueue,dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW,0));

//声明一个并行队列 优先级low

dispatch_queue_t concurrencyQueue = dispatch_queue_create("concurrentcy_queue",DISPATCH_QUEUE_CONCURRENCY);

dispatch_set_target_queue(concurrencyQueue,dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW,0));

串行队列 内执行顺序为有序 因为在同一线程中执行

 并行队列内执行顺序为无序 因为在不同线程中执行


上一篇 下一篇

猜你喜欢

热点阅读