Skip to content

Instantly share code, notes, and snippets.

@zhangkn
Created May 4, 2018 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhangkn/5202b338dee49adbf373fb7efaf0b33c to your computer and use it in GitHub Desktop.
Save zhangkn/5202b338dee49adbf373fb7efaf0b33c to your computer and use it in GitHub Desktop.
执行任务
// 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