No more pitfalls! NSOperation is the multithreading technology that Apple recommends !, Nsoperation Multithreading

Source: Internet
Author: User

No more pitfalls! NSOperation is the multithreading technology that Apple recommends !, Nsoperation Multithreading

First of all, let me declare that I like GCD more in actual development, because it is more convenient to use.
But what is the truth?
Apple actually recommends NSOperation, so I hope you will not mislead others in your blog.
In other words, the Objective-C language used by Apple Development Is Object-Oriented. How can she recommend process-oriented development based on C language? (This sentence is just a joke. Do not spray it ...)

About NSOperation

Many people, when talking about NSOperation in their blogsIt was launched by iOS2.0.This emphasizes that the later GCD released by iOS4.0 is the multithreading method recommended by Apple!
I don't think I can blame them all for this, because many people are learning through data query during development, and few are willing to read the information provided by Apple.Official documentation.
In fact, Apple specifically mentioned this in the official documentation that NSOperation was indeed launched by iOS2.0. At that time, NSOperation was implemented through NSThread, and the efficiency was indeed average, !!

After Apple launched GCD in iOS4.0, it rewritten NSOperation. Since then, the underlying NSOperation is implemented by GCD !!

Below is the original official document:

(Operation queues usually provide the threads used to run their operations. In OS X v10.6 and later, operation queues use the libdispatch library (also known as Grand Central Dispatch) to initiate the execution of their operations. As a result, operations are always executed on a separate thread, regardless of whether they are designated as concurrent or non-concurrent operations. In OS X v10.5, however, operations are executed on separate threads only if their isConcurrent method returns NO. If that method returns YES, the operation object is expected to create its own thread (or start some asynchronous operation); the queue does not provide a thread for it.)
Comparison between NSOperation and GCD:
Apple no longer limits the maximum number of concurrent threads.

That is to say, this is not good for GCD development, because GCD cannot control the maximum number of concurrent threads, and once the number of concurrent threads is too large... You know ~

So, in summary, Apple actually recommends that we use NSOperation in the development process, not GCD! Please pay attention to it during development ~

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.