Concurrency and Application Design (i)

Source: Internet
Author: User

In the early days of computer development, the maximum amount of work time per unit was a computer that could perform the clock speed determination through the CPU. However, as technology advances and processor design becomes more compact, physical constraints such as heat begin to limit the processor's maximum clock speed. As a result, chip manufacturers look for other ways to improve the overall performance of their chips. The solution is that they increase the number of processor cores on each chip. By increasing the number of cores, the single chip can perform more instruction chip size and thermal characteristics without increasing CPU speed or changing per second. The only question is how to use the other cores.

Detach thread

Although threads have existed for many years and continue to have their uses, they do not solve the general problem of performing multiple tasks in an extensible manner. Using threads, creating an extensible solution falls on the developer. You must decide how many threads to create and dynamically adjust the quantity according to system changes. Another problem is that your application takes on the cost of most of the creation and maintenance threads. Instead of relying on threads, Mac OS x and iOS take an asynchronous design approach to solving concurrency problems. Async functions have been present in the operating system for many years and are often used for tasks that may take quite a long time, such as reading data from disk. In the past, if an asynchronous function, what you wanted to do, did not exist at all, you would write your own async function and create your own thread. But now, Mac OS X and iOS provide technology that can perform any task asynchronously without having to manage threads on their own.

One of the techniques for starting an asynchronous task is GCG Grand Central Dispatch. This technique moves the thread management code that you will typically write to the system level. All you need to do is define the task you want to perform and add it to a proper distribution queue. GCD is responsible for creating the required threads and incorporating your tasks into those threads. Because thread management is now part of the system, GCD provides a holistic approach to task management and execution that is more efficient than traditional threads.

The execution queue is a few objective-c objects very much like the distribution queue. You define the tasks and then add them to the execution queue, like GCD, execute the queue operation queues master all the thread management to ensure that the task executes quickly and efficiently.

Here's some information about the distribution queue, the execution queue, and some other related asynchronous techniques.

Concurrency and Application Design (i)

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.