考察点
串行队列 + 同步,会死锁,(主要针对在同一queue队列中)
- (void)test1 {dispatch_queue_t queue = dispatch_queue_create("serial", DISPATCH_QUEUE_SERIAL);NSLog(@"1");dispatch_async(queue, ^{NSLog(@"2");dispatch_sync(queue, ^{NSLog(@"3");});NSLog(@"4");});NSLog(@"5");}2020-12-26 15:15:30.063692+0800 dd[21630:5252182] 12020-12-26 15:15:30.063937+0800 dd[21630:5252182] 52020-12-26 15:15:30.063951+0800 dd[21630:5252264] 2出现死锁奔溃现象:---------------------------------------------------------------Thread 3: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
**
假设换成并发队列,依旧有同步任务,不会死锁
- (void)test1 {dispatch_queue_t queue = dispatch_queue_create("con", DISPATCH_QUEUE_CONCURRENT);NSLog(@"1");dispatch_async(queue, ^{NSLog(@"2");dispatch_sync(queue, ^{NSLog(@"3");});NSLog(@"4");});NSLog(@"5");}


异步+并发队列,performSelector底层,线程与runloop
