Dispatch methods provided by the gcd-system

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.