iOS CGD dispatch_group_t 等待

来源:互联网 发布:软件学报 期刊ccf 编辑:程序博客网 时间:2024/05/21 20:27
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, ^{
        for (int i =0; i<100; i++)
        {
            NSLog(@"i------:%d",i);
        }
    });
    
    dispatch_group_async(group, queue, ^{
        for (int i =0; i<100; i++) {
            NSLog(@"j======:%d",i);
        }

    });


    dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
    dispatch_release(group);
    

    NSLog(@"dspath_group_async");
原创粉丝点击