zoukankan      html  css  js  c++  java
  • GCD和NSOperationQueue添加依赖的方法

    - (void)dispatchGroup

    {

        dispatch_group_t group = dispatch_group_create();

        dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

            NSLog(@"1--%@", [NSThread currentThread]);

        });

        dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

            NSLog(@"2--%@", [NSThread currentThread]);

        });

        dispatch_group_notify(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

            NSLog(@"3---%@", [NSThread currentThread]);

        });

     

    }

     

    - (void)operation

    {

        NSOperationQueue *queue = [[NSOperationQueue alloc] init];

        NSOperation *operation1 = [NSBlockOperation blockOperationWithBlock:^{

            NSLog(@"1---%@", [NSThread currentThread]);

        }];

        NSOperation *operation2 = [NSBlockOperation blockOperationWithBlock:^{

            NSLog(@"2---%@", [NSThread currentThread]);

        }];

        NSOperation *operation3 = [NSBlockOperation blockOperationWithBlock:^{

            NSLog(@"3---%@", [NSThread currentThread]);

        }];

        [operation1 addDependency:operation2];

        [operation2 addDependency:operation3];

        

        [queue addOperation:operation1];

        [queue addOperation:operation2];

        [queue addOperation:operation3];

    }

  • 相关阅读:
    第四篇Scrum冲刺博客
    第三篇Scrum冲刺博客
    蔡勒公式和吉姆拉尔森公式计算星期几
    事后诸葛亮
    Alpha阶段项目复审
    团队作业6——复审与事后分析
    第7篇 Scrum 冲刺博客
    第6篇 Scrum 冲刺博客
    第5篇 Scrum 冲刺博客
    第4篇 Scrum 冲刺博客
  • 原文地址:https://www.cnblogs.com/bing-ge/p/4606095.html
Copyright © 2011-2022 走看看