I. What is a process
A process is a single execution of a program, and a program is a binary and other type of data that is executable on disk.
The life cycle of a process: The program is read into memory, and its life cycle starts only when it is called by the operating system.
Each process has its own address space, memory, data stack, and other records of its running track of the auxiliary data, each process has its own memory space, data stack, etc., so the process can not directly share information, can only use interprocess communication.
Second, what is a thread
All threads run in the same process and share the same running environment. You can think of a thread as a "mini process" that runs in parallel in "main process" or "main thread".
Line threads start, sequence execution, and end three parts.
The sharing of the same piece of data space between threads in a process means that it is easier to share data and communicate with each other between threads.
?? Note that threads are generally run concurrently, but in a single CPU system, there is no real concurrency, because only one thread is using CPU resources at a time.
Iii. Summary
Each process has its own data space, so the inter-process communication and data sharing will be more complex;
Threads share the same runtime environment and share the same piece of data space, and data sharing and inter-thread communication are relatively straightforward.
In I/O intensive operation, multi-process and multi-threaded operation efficiency is relatively small;
In CPU-intensive operation, multi-process operation efficiency is higher than multithreading efficiency;
Python high-performance programming--001--threads and processes basic concepts