一、放在主線程中執(zhí)行:(特別是圖片加載之后帆精,再放到主線程執(zhí)行)
?// 1.放在主線程中加載
? ? [[NSOperationQueue mainQueue] addOperationWithBlock:^{
? ? }];
? ? // 2.主線程中加載
? ? dispatch_async(dispatch_get_main_queue(), ^{
? ? });
二、放在次線程中執(zhí)行:(定時器的開啟可以放在次線程中议忽;cell中圖片加載)
?dispatch_queue_t orderQueue = dispatch_queue_create("com.orders", nil);
? ? dispatch_async(orderQueue, ^{
}
三迫筑、執(zhí)行先后順序
dispatch_barrier_sync 需要等待柵欄執(zhí)行完才會執(zhí)行柵欄后面的任務(wù),而dispatch_barrier_async 無需等待柵欄執(zhí)行完,會繼續(xù)往下走(保留在隊列里)
四、延遲后執(zhí)行 ?
1.[NSThread sleepForTimeInterval:0.7];
2.?dispatch_after
五巩趁、一個頁面有幾個請求接口?
?dispatch_group_create()