- /**
- * 延时执行 dispatch_after
- */
- - (void)after {
- NSLog(@"begin");
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // 2 秒后异步到主队列开始执行
- NSLog(@"2 秒后:%@",[NSThread currentThread]);
- });
- NSLog(@"end");
- }
2.GCD 快速迭代: dispatch_apply
3.GCD 栅栏方法: dispatch_barrier_async
4.GCD 代码只执行一次:
来源: http://www.bubuko.com/infodetail-2787112.html