iOS gcd some ways to use

Source: Internet
Author: User

1- (void) gcdmethed{2     //Background Execution3Dispatch_async (Dispatch_get_global_queue (Dispatch_queue_priority_high,0), ^{4         5         //actions performed in the background6NSLog (@"Background Operation");7     });8     9     //Main thread ExecutionTenDispatch_async (Dispatch_get_main_queue (), ^{ One         A         //operations performed by the main thread -NSLog (@"Main thread Operation"); -     }); the      -      -     //Disposable Execution -      for(intI=0; i<2; i++) { +         Staticdispatch_once_t Oncetoken; -Dispatch_once (&oncetoken, ^{ +             //code executes once ANSLog (@"code executes once"); at         }); -     } -      - //2 seconds delay execution -     DoubleDelayinseconds =2.0; -dispatch_time_t poptime = Dispatch_time (Dispatch_time_now, (int64_t) (Delayinseconds *nsec_per_sec)); inDispatch_after (Poptime, Dispatch_get_main_queue (), ^ (void){ -NSLog (@"delayed 2 seconds of execution"); to     }); +      -     //Custom dispatch_queue_t thedispatch_queue_t Urls_queue = Dispatch_queue_create ("blog.devtang.com", NULL); *dispatch_queue_t urls_queue2 = Dispatch_queue_create ("TEST", dispatch_queue_concurrent);//Parallel Queue dispatch_queue_serial Walkthrough Queue $Dispatch_async (Urls_queue, ^{Panax Notoginseng          -     }); the //dispatch_release (Urls_queue); ARC does not need +      A      the     //Merge Summary Results +      -dispatch_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), ^{ the             //threads executed in parallel two -     });WuyiDispatch_group_notify (Group, Dispatch_get_global_queue (0,0), ^{ the             //Summary Results -     }); Wu      -Dispatch_async (Dispatch_get_global_queue (Dispatch_queue_priority_default,0), ^{ About         $Dispatch_async (Dispatch_get_main_queue (), ^{ -              -         }); -     }); A      +}

iOS gcd some ways to use

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.