GCD provides and manages FIFO queues to which your application can submit tasks in the form of block objects. Blocks submitted to dispatch queues are executed on a pool of threads fully managed by the system. No guarantee is made as to the thread on which a task executes. GCD offers three kinds of queues:
-
Main:
tasks execute serially on your application’s main thread -
Concurrent:
tasks are dequeued in FIFO order, but run concurrently and can finish in any order. -
Serial:
tasks execute one at a time in FIFO order
The main queue is automatically created by the system and associated with your application’s main thread. Your application uses one (and only one) of the following three approaches to invoke blocks submitted to the main queue:
-
Calling
dispatch_main
-
Calling
UIApplicationMain
(iOS) or NSApplicationMain
(OS X) -
Using a
CFRunLoopRef
on the main thread
Use concurrent queues to execute large numbers of tasks concurrently. GCD automatically creates three concurrent dispatch queues that are global to your application and are differentiated only by their priority level. Your application requests these queues using the dispatch_get_global_queue
Use serial queues to ensure that tasks to execute in a predictable order. It’s a good practice to identify a specific purpose for each serial queue, such as protecting a resource or synchronizing key processes. Your application must explicitly create and manage serial queues. It can create as many of them as necessary, but should avoid using them instead of concurrent queues just to execute many tasks simultaneously.
Important:
dispatch_async
dispatch_async_f
dispatch_sync
dispatch_sync_f
dispatch_after
dispatch_after_f
dispatch_apply
dispatch_apply_f
dispatch_once
dispatch_async
dispatch_async_f比较,它们之音的区别就是多了一个_f,再就是用_f多了一个参数,其它的好像没什么区别,官网上也没查到
//
//
//