This from the practice of simple explanation:
First, GCD is the acronym for the Grand Central Dispatch, meaning multithreading optimization technology, which is optimized for multi-core processing by Apple. Easy to use and clear.
Multithreading is divided into synchronous, asynchronous methods as follows:
// Asynchronous Thread Open: dispatch_async (dispatch_queue_t queue, ^ (void) block)// sync thread on: Dispatch_sync (dispatch_queue_t queue, ^ (void//dispatch_queue_t: Queue block: Execution content
Description of the queue:
The creation method is as follows:
Dispatch_queue_create (constchar *label, dispatch_queue_attr_t attr)
Parameter description: Label for queue name attr as queue serial: Dispatch_queue_serial parallel: dispatch_queue_concurrent
Special Queue Description:
The system defaults to a serial queue main_queue and parallel queue Global_queue using the following methods:
Dispatch_get_main_queue ()// home row dispatch_get_global_queue (longlong flags) ; /* Identifler: Priority * -Dispatch_queue_priority_high: 2 * -Dispatch_queue_priority_default: 0 * -dispatch_queue_priority_low: -2 * */
Finally, special threads:
//The thread after which the previous thread ends after executing this thread ends before executing itDispatch_barrier_async (dispatch_queue_t queue, ^ (void) block) Dispatch_barrier_sync (dispatch_queue_t queue,^(void) block)//number of thread iterations repeatedly executedDispatch_apply (size_t iterations, dispatch_queue_t queue, ^(size_t) block)//Execute only onceStaticdispatch_once_t Oncetoken; Dispatch_once (&oncetoken, ^{ //code to be executed once }); //Deferred execution nsec_per_sec secdispatch_time_t poptime = Dispatch_time (Dispatch_time_now, Delayinseconds *nsec_per_sec); Dispatch_after (Poptime, Dispatch_get_main_queue (),^(void){ //Code to is executed on the main queue after delay }); //set the priority of a dispatch queuevoidDispatch_set_target_queue (dispatch_object_tObject, dispatch_queue_t queue)
iOS GCD Simple Introduction