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

    }

  • 相关阅读:
    .NET中获取系统硬件信息
    TTF文件的制作——打造属于自己的字体
    HDU4415 Assassin’s Creed
    HDU4193 Nonnegative Partial Sums(单调队列)
    HDU4414 Finding crosses
    HDU4407 Sum
    HDU4403 A very hard Aoshu problem
    HDU4417 Super Mario
    HDU4419 Colourful Rectangle
    非递归快速排序和非递归快速乘幂
  • 原文地址:https://www.cnblogs.com/bing-ge/p/4606095.html
Copyright © 2011-2022 走看看