dispatch_queue_t myQueue = dispatch_queue_create("com.team", NULL);
NSLog(@"task1 == %@",[NSThread currentThread]);
dispatch_sync(myQueue, ^{
// task2 为什么在主线程执行,不是应该在block追加到的线程执行吗,就像task4一样,block里的线程应该和 dispatch_sync 的第一个参数的线程相同
NSLog(@"task2 == %@",[NSThread currentThread]);
});
dispatch_async(myQueue, ^{
NSLog(@"task3 == %@",[NSThread currentThread]);
dispatch_sync(dispatch_get_main_queue(), ^{
NSLog(@"task4 == %@",[NSThread currentThread]);
});
});
![图片说明](https://img-ask.csdn.net/upload/201603/24/1458802918_681208.png)