首页 > 代码库 > dispatch_group_async
dispatch_group_async
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. 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]; [self group1]; }); dispatch_group_async(group, queue, ^{ [NSThread sleepForTimeInterval:5]; [self group2]; }); dispatch_group_async(group, queue, ^{ [NSThread sleepForTimeInterval:10]; [self group3]; }); dispatch_group_notify(group, dispatch_get_main_queue(), ^{ NSLog(@"updateUi"); }); dispatch_release(group); } - (void)group1 { NSLog(@"%s", __FUNCTION__); } - (void)group2 { NSLog(@"%s",__FUNCTION__); } - (void)group3 { NSLog(@"%s",__FUNCTION__); }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。