iOS:GCD组

组内异步会与组外顺序执行的事件争抢资源

1)、创建一个组

dispatch_group_t group = dispatch_group_create();

 

2)、组内异步ST1,DISPATCH_QUEUE_PRIORITY_DEFAULT 为默认优先级

dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

	//do something 1

    });

 

3)、组内异步ST2,DISPATCH_QUEUE_PRIORITY_DEFAULT 为默认优先级

dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

	//do something 2

    });

 

4)、组内通知,获取主线程。组内异步全部执行完就到这里

dispatch_group_notify(group, dispatch_get_main_queue(), ^{

	//组内全部完成 再 do something

    });

 

 

5)、组外ST3

//do something 3
posted on 2016-12-06 14:14  leonlincq  阅读(330)  评论(0编辑  收藏  举报