iOS Threading summary (continuous update ing)

Source: Internet
Author: User

First, what is a thread:

1, a process to perform tasks, must have a thread (at least 1 threads per 1 processes)

2, the thread is the basic execution unit of the process, all tasks of a process (program) are executed in thread

3, 1 threads in the execution of the task is serial, if you want to perform multiple tasks in 1 threads, then you can only perform these tasks sequentially, that is, at the same time, 1 threads can only perform one task

Second, what is multi-threaded

1. Multiple threads can be opened in one process, each thread can perform different tasks in parallel (at the same time)

Example: Process--workshop, threading--workshop workers

2, the principle of multi-threading: The same time, the CPU can only handle 1 threads, only 1 threads in the work (execution), multi-threaded concurrency (at the same time) execution, its essence is the CPU quickly between the multi-thread scheduling (switching), when the CPU scheduler thread speed enough block, resulting in multi-threaded concurrent execution of the illusion

Third, what is the main thread

1. After an iOS program runs, 1 threads are turned on by default to become the main thread or UI thread

2. Main function: Display, refresh UI interface, handle UI events (such as click events, scrolling events, drag events, etc.)

3, use the main thread need to note: Do not put more time-consuming operations on the main thread, the card UI (blocking UI)

Iv. implementation of multi-threading in iOS

1, Pthread

Introduction: A set of generic threading API for Unix\linux\windows and other systems, cross-platform, portable, and difficult to use.

Language: C

Thread Life cycle: Programmer Management

Frequency of use: almost no

2, Nsthread

Summary: Use more object-oriented, easy-to-operate, direct manipulation of thread objects

Language: OC

Thread Life cycle: Programmer Management

Frequency of Use: occasional use

3, GCD

Introduction: Designed to replace threading technology such as Nsthread to take full advantage of device multicore

Introduction: C

Thread life cycle: automatic management

Frequency of use: frequently used

4, Nsoperation

Introduction: Based on CGD (bottom is gcd), more than gcd more simple and practical functions, using more object-oriented

Language: OC

Thread life cycle: automatic management

Frequency of use: frequently used

iOS Threading summary (continuous update ing)

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.