码迷,mamicode.com
首页 > 其他好文 > 详细

dispatch_group_async

时间:2014-06-12 13:02:38      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   java   http   

bubuko.com,布布扣
- (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__);
}
bubuko.com,布布扣

 

dispatch_group_async,布布扣,bubuko.com

dispatch_group_async

标签:style   class   blog   code   java   http   

原文地址:http://www.cnblogs.com/joesen/p/3782164.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!