1、 main_queue中追加block
dispatch_apply(10, dispatch_get_main_queue(), ^(size_t index) {
NSLog(@"index:%zu %@",index,[NSThread currentThread]);
});
2、main_queue中添加同步任务
dispatch_sync(dispatch_get_main_queue(), ^{
})
3、main_queue添加同步barrier
dispatch_barrier_sync(dispatch_get_main_queue(), ^{
NSLog(@"2 %s",__func__);
});
网友评论