iOS dispatch_group_async 多个任务处理完再执行其他操作

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

dispatch_group_t group = dispatch_group_create();

dispatch_group_async(group, queue, ^{

[NSThread sleepForTimeInterval:1];

NSLog(@"group1");

});

dispatch_group_async(group, queue, ^{

[NSThread sleepForTimeInterval:2];

NSLog(@"group2");

});

dispatch_group_async(group, queue, ^{

[NSThread sleepForTimeInterval:3];

NSLog(@"group3");

});

dispatch_group_notify(group, dispatch_get_main_queue(), ^{

NSLog(@"updateUi");

});

dispatch_release(group);

你可能感兴趣的:(iOS dispatch_group_async 多个任务处理完再执行其他操作)