Multithread when to deal with multi-threading, there are several ways, pros and cons?

Source: Internet
Author: User
Tags gcd

1. In IOS programming, there are several situations where multithreading is required: UI events must be performed on the mainline thread, others can be performed in the background, and tasks that are time-consuming or blocking threads are finally placed in the background line thread.

There are several multithreading techniques for 2.iOS: threads, GCD, and Nsoperationqueue (Operation Queues).

3. Threading this technique is more complex, but the thread has a later advantage: the ability to accurately guarantee the time of task execution. GCD full name is the Grand Central Dispatch, is libdispatch the external code of this library, based on the bottom of C to implement, and Nsoperationqueue, commonly known as the Operation queue, is based on GCD implementation. GCD can do nsoperationqueue basically can do, and there are some GCD features that are not easy to implement, such as suspend, cancel the task, although in IOS 8, GCD also provides the ability to cancel the task, but in the GCD of the task hangs and cancellations have a greater limitation; though most of the cases Should use a higher level of abstraction API, that is, nsoperationqueue, but to handle the general background tasks I prefer GCD, mainly GCD collocation blcok easy to use, very convenient.

Multithread when to deal with multi-threading, there are several ways, pros and cons?

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.