zoukankan      html  css  js  c++  java
  • GCD 多线程同步

    @property (strong, nonatomic) dispatch_queue_t barrierQueue;

    _barrieQueue = dispatch_queue_create("Juanpi.BarrieQueue.queue", DISPATCH_QUEUE_CONCURRENT);

        

        dispatch_async(self.barrieQueue, ^{

            NSLog(@"线程1执行了 currentThread = %@",[NSThread currentThread]);

        });

        

        dispatch_async(self.barrieQueue, ^{

            NSLog(@"线程2执行了 currentThread = %@",[NSThread currentThread]);

        });

        

        dispatch_async(self.barrieQueue, ^{

            NSLog(@"线程3执行了 currentThread = %@",[NSThread currentThread]);

        });

        dispatch_async(self.barrieQueue, ^{

            NSLog(@"线程4执行了 currentThread = %@",[NSThread currentThread]);

        });

        dispatch_async(self.barrieQueue, ^{

            NSLog(@"线程5执行了 currentThread = %@",[NSThread currentThread]);

        });

        dispatch_async(self.barrieQueue, ^{

            NSLog(@"线程6执行了 currentThread = %@",[NSThread currentThread]);

        });

        

        dispatch_barrier_async(self.barrieQueue, ^{

            NSLog(@"barrierrQueue currentThread = %@",[NSThread currentThread]);

        });

        

        dispatch_async(self.barrieQueue, ^{

            NSLog(@"线程7执行了 currentThread = %@",[NSThread currentThread]);

        });

  • 相关阅读:
    Redis 高级数据结构:五、哈希对象
    Redis 高级数据结构:四、列表对象
    Redis 高级数据结构:三、字符串对象
    Redis 高级数据结构:二、简介
    总结1
    Windows程序代码重构
    Windows应用程序结构
    事件、消息循环和窗口函数
    窗口的创建和显示
    Windows的数据类型
  • 原文地址:https://www.cnblogs.com/AlvinCrash/p/5614681.html
Copyright © 2011-2022 走看看