美文网首页
iOS-任务依赖-while

iOS-任务依赖-while

作者: 笑破天 | 来源:发表于2022-09-27 15:03 被阅读0次

NSOperation、dispatch_semaphore_t、子线程while

子线程while:

- (void)viewDidLoad {
    [super viewDidLoad];
    queue = dispatch_queue_create("com.xx.test", DISPATCH_QUEUE_SERIAL);
    [self test];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    dic = [NSDictionary dictionary];
}

- (void)test {
    dispatch_async(queue, ^{
        BOOL finish = NO;
        while (!finish) {
            if (self->dic) {
                NSLog(@"done");
                finish = YES;
            }
        }
    });
}

相关文章

网友评论

      本文标题:iOS-任务依赖-while

      本文链接:https://www.haomeiwen.com/subject/nlwfartx.html