The dispatch queue is divided into the following three types:
1) Run the main queue in the main thread, obtained through Dispatch_get_main_queue.
2) Parallel queue Global dispatch queue, obtained by Dispatch_get_global_queue, creates three different priority dispatch queues by the system. Parallel queues are executed in the same order as they join the queue.
3) Serial queue serial queues is typically used to synchronize access sequentially, creating any number of serial queues that are concurrent between each serial queue.
Background execution: Dispatch_async (dispatch_get_global_queue (0, 0), ^{//Something}); Main thread execution: Dispatch_async (Dispatch_get_main_queue (), ^{//Something}); Disposable execution: Static dispatch_once_t Oncetoken; Dispatch_once (&oncetoken, ^{//code to be executed once}); Delay 2 seconds execution: double delayinseconds = 2.0; dispatch_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}); Custom dispatch_queue_t dispatch_queue_t urls_queue = dispatch_queue_create ("blog.devtang.com", NULL); Dispatch_async (Urls_queue, ^{//Your code}); Dispatch_release (Urls_queue); Merge Summary results dispatch_group_t group = dispatch_group_create (); Dispatch_group_async (Group, Dispatch_get_global_queue (0,0), ^{//parallel execution of thread one}); Dispatch_group_async (Group, Dispatch_get_global_queue (0,0), ^{//Parallel execution thread two}); Dispatch_group_notify (Group, Dispatch_get_global_queue (0,0), ^{ Aggregated results});
IOS GCD Common