Summary of python/process threads
Description of the process and thread:
Process: The smallest resource management unit
Threads: the smallest execution unit
Executes a thread by default (main thread) when executing a process
How processes and threads work:
Serial:
If there is a, B, C tasks, the serial execution process is the first to perform a task, a task after the completion of the B task, b task after the completion of the final C task execution.
Concurrent:
If there is a, B, c tasks, the parallel execution process is to perform a task for a period of time, switch to the B task for a period of time, switch to the C task, until a, B, c three tasks are completed.
Parallel:
If there is a, B, c task, the concurrent execution process is executing a, B, and C tasks at the same time but must have multiple processors (CPUs)
CPython because the existence of the Gil causes only one thread in the same process to execute at the same time
About Daemon: The program does not exist until the daemon thread exits
Sync Lock: Public data is processed by multithreading (it can cause data errors to be locked)
Deadlock: In a process there are multiple threads in the acquisition of the user lock, the same time different threads to get two locks, want to interact with the time when no one released to wait for each other to release, resulting in a deadlock situation
Recursive lock: The inside of a recursive lock has a counting mechanism, and when a thread gets it, it adds one. There is a process that is freed once to subtract one. Note (the default value is 0, when the lock value is not 0 o'clock, all processes are not available)
Summary of python/process threads