美文网首页
GCD多线程

GCD多线程

作者: ZeWeiZhang | 来源:发表于2017-02-24 16:33 被阅读0次

//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);

//    });

相关文章

网友评论

      本文标题:GCD多线程

      本文链接:https://www.haomeiwen.com/subject/akpwwttx.html