Python | Difference between process and thread

Difference between process and thread


threads and processes
Function

process, can complete multiple tasks, such as running multiple QQ on one computer at the same time.
Threads can complete multitasking, such as multiple chat windows in a QQ.
different definitions

A process is an independent unit of resource allocation and scheduling in the system.
A thread is an entity of a process and the basic unit of CPU scheduling and dispatching. It is a basic unit smaller than a process that can run independently. The thread itself basically does not own system resources, but only has a few resources that are essential for operation. (such as the program counter, a set of registers and stacks), but it can share all the resources owned by the process with other threads belonging to the same process.
the difference

A program has at least one process, and a process has at least one thread.
The division scale of threads is smaller than that of processes (with fewer resources than processes), which makes multi-threaded programs have high concurrency.
A process has an independent memory unit during execution, and multiple threads share memory, which greatly improves the running efficiency of the program.
Threads cannot execute independently and must depend on processes.
The process can be understood as an assembly line in the factory, and the threads in it are the workers on the assembly line

Advantages and disadvantages
Threads and processes have their own advantages and disadvantages: thread execution overhead is small, but it is not conducive to resource management and protection; while process is the opposite.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00