Process
The program does not run alone, only the program is loaded into memory, the system allocates resources to run, and this execution of the program becomes a process, program and process differences, the program is a set of instructions, it is a static description of the process running text, process is a program execution activity, is a dynamic concept
Why do I have to thread the process?
Process can only do one thing at the same time
If the process is blocked during execution, such as waiting for input, the entire process hangs, even if some work in the process does not depend on this input data, it will not be able to execute
Thread
The line city is the smallest unit that the operating system can perform operation scheduling, which is contained in the process and is the actual running unit of the process.
The difference between a process and a thread
Thread sharing creates its memory space for the process, and the process has its own independent memory space
A thread can directly access the data segment of its process, and the process has its own copy of the data segment of the parent process
Threads can communicate directly with other threads of their processes, and processes must communicate with sibling processes using interprocess communication
Creating a thread is easy, and creating a process requires copying the parent process
Changes to the main thread (cancellation, priority changes, etc.) may affect the behavior of other threads of the process, and changes to the parent process do not affect the child process
Gil Lock, Global interpreter lock
No matter how many threads are started, the computer has more than one cpu,python at the same time to allow only a single thread to run at the time of execution
The Gil is not a Python feature, it is a concept introduced when implementing the Python interpreter CPython
This article is from the "Eight Miles" blog, so be sure to keep this source http://5921271.blog.51cto.com/5911271/1907232
Python Route 44-process and thread differences and Gil Global interpreter lock