并发数据请求1

dispatch_group_t group = dispatch_group_create();

dispatch_queue_t queue = dispatch_queue_create("queue", DISPATCH_QUEUE_SERIAL);

dispatch_group_enter(group);

dispatch_group_async(group, queue, ^{

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

NSLog(@"任务1");

dispatch_group_leave(group);

});

});

dispatch_group_enter(group);

dispatch_group_async(group, queue, ^{

NSLog(@"任务2");

dispatch_group_leave(group);

});

dispatch_group_enter(group);

dispatch_group_async(group, queue, ^{

NSLog(@"任务3");

dispatch_group_leave(group);

});

dispatch_group_notify(group, queue, ^{

NSLog(@"完成");

});


著作權歸作者所有。商業轉載請聯繫作者獲得授權,非商業轉載請註明出處。

你可能感兴趣的:(并发数据请求1)