Created
May 4, 2018 06:42
-
-
Save zhangkn/5202b338dee49adbf373fb7efaf0b33c to your computer and use it in GitHub Desktop.
执行任务
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GCD中有2个用来执行任务的函数 | |
//1) 用同步的方式执行任务 | |
dispatch_sync(dispatch_queue_t queue, dispatch_block_t block);//queue:队列 block:任务 | |
//2) 用异步的方式执行任务 | |
dispatch_async(dispatch_queue_t queue, dispatch_block_t block); | |
// 同步和异步的区别 | |
同步:只能在当前线程中执行任务,不具备开启新线程的能力 | |
异步:可以在新的线程中执行任务,具备开启新线程的能力 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment