1. 主隊(duì)列中的任務(wù)就是在主線程執(zhí)行
dispatch_sync(dispatch_get_main_queue(), ^{
? ? ?[NSThread sleepForTimeInterval:1.0];//讓主線程睡一秒
NSLog(@"更新UI = %@",[NSThread currentThread]);
});
2.異步
dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSLog(@"下載任務(wù) = %@",[NSThread currentThread]);
});