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];

    }

  • 相关阅读:
    windows 命令修改IP
    iptables_forward
    python之pickle模块
    python之os.path模块
    python之random模块
    python基础之常用模块
    python基础之测试题
    python 集合(set)基础
    python编码与解码
    python3 字符串基础
  • 原文地址:https://www.cnblogs.com/bing-ge/p/4606095.html
Copyright © 2011-2022 走看看