The dispatch methods provided by the system are as follows:
//dispatch methods provided by the system//Background execution:Dispatch_async (Dispatch_get_global_queue (0,0), ^{ //something }); //main thread Execution:Dispatch_async (Dispatch_get_main_queue (), ^{ //something }); //Disposable Execution: Staticdispatch_once_t Oncetoken; Dispatch_once (&oncetoken, ^{ //something }); //delay of 2 seconds execution: DoubleDelayinseconds =2.0; dispatch_time_t Poptime= Dispatch_time (Dispatch_time_now, Delayinseconds *nsec_per_sec); Dispatch_after (Poptime, Dispatch_get_main_queue (),^(void){ //delay 2s execution in the main thread }); //Custom Queuedispatch_queue_t Urls_queue = Dispatch_queue_create ("blog.devtang.com", NULL); Dispatch_async (Urls_queue,^{ //something }); //let the background 2 threads execute in parallel, and wait until 2 threads are finished, then summarize the execution resultsdispatch_group_t Group =dispatch_group_create (); Dispatch_group_async (Group, Dispatch_get_global_queue (0,0), ^{ //thread one in parallel execution }); Dispatch_group_async (Group, Dispatch_get_global_queue (0,0), ^{ //threads executed in parallel two }); Dispatch_group_notify (Group, Dispatch_get_global_queue (0,0), ^{ //Summary Results});
Resources:
http://www.devtang.com/blog/2012/02/22/use-gcd/
Http://www.cnblogs.com/pure/archive/2013/03/31/2977420.html
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Dispatch methods provided by the gcd-system