GCD多线程

//1、串行队列

dispatch_queue_t queue_1 = dispatch_queue_create("hehehe", NULL);

//2、并行队列

dispatch_queue_t queue_2 = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

//3、获取主队列

dispatch_queue_t queue_main = dispatch_get_main_queue();

//函数

//1、同步函数

//    dispatch_sync(queue_1, ^{

////        NSLog(@"sync_1");

//        NSThread * thread = [NSThread currentThread];

//        NSLog(@"sync_1 = %@",thread);

//

//    });

//    dispatch_sync(queue_2, ^{

//        NSThread * thread = [NSThread currentThread];

//        NSLog(@"sync_2 = %@",thread);

//    });

//

//    dispatch_sync(queue_main, ^{

//        NSThread * thread = [NSThread currentThread];

//        NSLog(@"sync_M = %@",thread);

//    });

//2、异步函数

//    dispatch_async(queue_1, ^{

////        NSLog(@"asycn——1111");

//        NSThread * thread = [NSThread currentThread];

//        NSLog(@"sync_1 = %@",thread);

//    });

//

//    dispatch_async(queue_2, ^{

//        NSThread * thread = [NSThread currentThread];

//        NSLog(@"sync_2 = %@",thread);

//    });

//

//    dispatch_async(queue_main, ^{

//        NSThread * thread = [NSThread currentThread];

//        NSLog(@"sync_M = %@",thread);

//    });

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容