OC Advanced Programming iOS Multithreading personal understanding One

Source: Internet
Author: User

Most of the notes are from: objective-c Advanced Programming (iOS and OS Multithreading and memory management), a bit of a long time, even GCD Online said no need to manually release releases, but the book emphasizes the use of GCD need to manage their own count.

First of all, what is GCD?

This is an API for Apple to make it easier for developers to focus on the task execution content in multi-threading, the official note: Developers need to define the tasks they want to perform and append them to the appropriate dispatch queue. is a C language but is formed into a face-like object style. He is one of the techniques we are using to perform tasks asynchronously. and a pthread,nsthread,nsoperation,nsoperationqueue.

First of all, we have a main thread in the app, which is usually done here, especially a large part of the UI is to be updated on the main thread, while some network requests are not in the main thread update, in order to avoid the application card owner or blocking the user's exchange.

In GCD, Dispatchqueue is divided into two kinds, one is called serial queue (Serial Dispatch queue), and the other is parallel queue (Concurrent Dispatch queue), The tasks that we need to perform are generally described in block syntax and are added to the dispatch queue for execution.

The tasks in the serial team are performed according to the queue task, followed by the FIFO method to execute the block loaded in the queue (that is, what we need to do). when a block is not completed, the block behind the queue will not be executed! One must come!

 However, the parallel queue does not need to wait, that is, the previous block is not finished, the following block will also be executed, is more than one block simultaneous execution! There is no need to wait for the end.

OC Advanced Programming iOS Multithreading personal understanding One

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.