process:
1. The basic unit for resource allocation and scheduling by the operating system, multiple processes are independent of each other
2. Good stability. If a process crashes, it will not affect other processes, but the process consumes a lot of resources, and the number of open processes is limited.
Thread:
1. The basic unit for CPU resource allocation and scheduling. A thread is a part of a process. It is a smaller basic unit that can run independently. Multiple threads under a process can share all resources of the process.
2. If the IO operation is intensive, you can run multi-threaded with high efficiency. The disadvantage is that if a thread crashes, it will cause the process to crash.
application:
IO intensive use of multi-threading, during user input, during sleep, you can switch to other threads for execution, reducing the waiting time
CPU-intensive use of multiple processes, because if there are few IO operations and multiple threads, because threads share a global interpreter lock, the currently running thread will occupy the GIL, and other threads without GIL cannot fully take advantage of the multi-core CPU.