Multi-thread pthread, Nsthread, Nsoperation, GCD

Source: Internet
Author: User
Tags gcd

There are a number of multithreading that will be as follows:
Multi-Thread Concept analysis

Multi-thread pthread, Nsthread, Nsoperation, GCD

Multi-Thread Nsthread

Multi-Thread Nsoperation

Multi-thread GCD



Pthread
: Cross-platform, applicable to a variety of operating systems, portability, is a set of pure C language Common API, and the thread life cycle needs the programmer to manage their own, the use of more difficult, so in actual development is usually not used.

Nthread: It's an apple package for pthread. Through encapsulation, you can use multithreading more easily in a cocoa environment. The life cycle of a thread is managed by the programmer. Each Nsthread object corresponds to a thread that is really the most primitive thread.

1) Advantages: Nsthread lightweight minimum, relatively simple.

2) Cons: Manually manage some thread activity, such as lifecycle, thread synchronization, sleep, etc.

nsoperation : Based on the OC language API, the bottom layer is GCD, adding some more simple-to-use features, using more object-oriented. The life cycle of a thread is automatically managed by the system.

1) Advantages: Self-threading cycle management, the operation can pay more attention to their own logic.

2) Cons: Object-oriented abstract class, can only implement it or use it to define two sub-classes: Nsinvocationoperation and Nsblockoperation

GCD : ios4.0, based on the C language API, takes full advantage of the multi-core of the device and is designed to replace threading technology such as Nsthread. The life cycle of a thread is automatically managed by the system.
1) Advantages: maximum efficiency, avoid concurrency traps.
2) Cons: Based on C implementation.


Multi-thread pthread, Nsthread, Nsoperation, GCD

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.