原文地址:www.cnblogs.com/wendingding/p/3806821.html
GCD中有2个核心概念
(1)任务:执行什么操作 ==> 同步任务:dispatch_sync(dispatch_queue_t queue, dispatch_block_t block);异步任务:
dispatch_async(dispatch_queue_t queue, dispatch_block_t block);(2)队列:用来存放任务==>串行队列:dispatch_queue_create(const char *label, dispatch_queue_attr_t attr); 或 dispatch_get_main_queue(); 并发队列:dispatch_get_global_queue(dispatch_queue_priority_t priority,unsigned long flags);
2.补充说明
有4个术语比较容易混淆:同步、异步、并发、串行
同步和异步决定了要不要开启新的线程
同步:在当前线程中执行任务,不具备开启新线程的能力
异步:在新的线程中执行任务,具备开启新线程的能力
并发和串行决定了任务的执行方式
并发:多个任务并发(同时)执行
串行:一个任务执行完毕后,再执行下一个任务