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

//    });

你可能感兴趣的:(GCD多线程)