Multithreading of iOS Development (1)-Overview

Collected Works

Multithreading for iOS development (1)
-Overview of multithreading for iOS development (2)-Multithreading for Thread
iOS development (3)-Multithreading for GCD
iOS development (4)
-Operation Multithreading for iOS development ( 5)-Multithreading of Pthreads
iOS development (6)-Thread safety and various locks

Overview

This series of articles will discuss the following multi-threaded programming methods in iOS:

Programmatically Language description Attendance rate Thread cycle
Thread OC/Swift Lightweight, easy to use in Manual management
GCD C Can make full use of the device's multi-core high Automatic management
Operation OC/Swift Based on GCD package, some practical methods have been added high Automatic management
Pthreads C Can be used across platforms low Manual management

Process and thread

What is a process? A
process is a process of dynamic execution of a program with a certain independent function on a data set. It is an independent unit of the operating system for resource allocation and scheduling, and is the carrier of application programs. Process is an abstraction There has never been a unified standard definition. In iOS, an App is a process.

Why processes can run in parallel?
CPU execution code is executed sequentially, but because the system can allow each process (application) to execute alternately quickly, making each process appear to be running at the same time. Only a multi-core CPU can truly achieve multiple processes Run at the same time.

Why thread?
With the development of computers, CPU requirements are getting higher and higher, and switching between processes is expensive, and it can no longer meet the requirements of more and more complex programs. God said that there must be threads, so there is Thread.

What is a thread? A
thread is a single sequential control flow in program execution. It is the basic unit of CPU scheduling and dispatch. It can share all the resources owned by the process with other threads that belong to the same process. A
thread is a part of a process. There is at least one thread in the process.

Why threads can run in parallel?
Like processes, it is also because the CPU switches quickly between task scheduling.

The main difference?
Process is the basic unit of the operating system for resource allocation and scheduling; thread is the basic unit of CPU scheduling and dispatch.

One picture in a nutshell ( picture source ):

Multithreaded.png

Guess you like

Origin blog.csdn.net/u012078168/article/details/107066576