iOS advanced face question----multi-line Cheng education

Source: Internet
Author: User
Tags gcd

1 Multi-Threading is what multithreading is a complex concept, the literal meaning is to complete a number of tasks synchronously, improve the use of resources efficiency, from the hardware, operating system, application software from different angles to see, multithreading is given different connotations, for hardware, now on the market most of the CPU is multicore, Multi-core CPU operation multithreading is better, from the operating system point of view, is multi-tasking, now use the mainstream operating system are multi-tasking, can listen to songs, while writing blogs; for applications, multithreading allows applications to respond faster and respond to users ' touch actions while the network is downloading. In the iOS application, the first understanding of multithreading is concurrency, it is the original meaning is to do water, then pick vegetables, and then stir-fry the work, will become boiling water to pick vegetables, and finally to stir-fry. 2 multi-threaded iOS in iOS, is multi-threaded in the cocoa framework, through the cocoa package, we can make it easier to use threads, C + + students may have more understanding of the thread, such as the creation of threads, semaphores, shared variables are aware of, Cocoa framework will be much more convenient, it is a thread encapsulation, some encapsulation, can let us create the object, itself has the thread, that is, the thread of the object of abstraction, thereby reducing our engineering, the robustness of the provider. GCD is the abbreviation for (Grand Central Dispatch), an easy-to-use multi-threaded class library available at the system level, with runtime features to take advantage of multi-core hardware. GCD API interface for C language functions, function parameters, most of the block, about the use of block see here, for us to provide a strong "interface", for the use of GCD see this article nsoperation and Queuensoperation is an abstract class, It encapsulates the thread's detail implementation, and we can manage multithreaded programs by subclasses of the object, plus nsqueue to object-oriented thinking.   See here: A nsoperation-based multi-threaded network Access project. Nsthreadnsthread is a control thread execution object, it is not as nsoperation abstract, through which we can easily get a thread, and control it. However, concurrency control between nsthread threads is required to be controlled by ourselves and can be implemented by Nscondition. Seethe use of Nsthread for iOS multithreaded programmingOther multithreading in the framework of cocoa, notifications, timer and asynchronous functions are used in multiple threads (to be supplemented). 3 iOS multi-line Chengchang meet questions when will the project choose to use GCD, when to choose Nsoperation? The advantage of using nsoperation in a project is that Nsoperation is a high abstraction of the thread, using it in the project, will make the program structure of the project better, the sub-class nsoperation design idea, is has the object-oriented advantage (multiplexing, encapsulation), so that the implementation is multi-threaded support, The interface is simple and recommended for use in complex projects. The advantage of using GCD in a project is that the GCD itself is very simple and easy to use, saving code for uncomplicated multithreaded operations, and the use of block parameters is more readable and recommended for simple projects.

iOS advanced face question----multi-line Cheng education

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.