iOS 多线程之间有依赖时的处理方式

iOS 多线程之间有依赖时的处理方式
dispatch_queue_t queue = dispatch_queue_create("queue", DISPATCH_QUEUE_CONCURRENT);
  dispatch_group_t group = dispatch_group_create();
  
  dispatch_group_async(group, queue, ^{
    dispatch_group_enter(group);
    NSLog(@"first API got data");
  });
  
  dispatch_group_async(group, queue, ^{
    dispatch_group_enter(group);
    NSLog(@"second API got data");
  });
    
  dispatch_group_leave(group);
  dispatch_group_leave(group);
  
  dispatch_group_notify(group, dispatch_get_main_queue(), ^{
    NSLog(@"UI refresh now");
  });

你可能感兴趣的:(iOS 多线程之间有依赖时的处理方式)