Mastering Python for Networking and Security
上QQ阅读APP看书,第一时间看更新

Introduction to Multithreading

The idea behind multithreading applications is that they allow us to have copies of our code and execute them on additional threads. This allows a program to execute multiple operations simultaneously. In addition, when a process is blocked, for example to wait for input/output operations, the operating system can allocate computation time to other processes.

When we mention multiprocess processors, we're referring to a processor that can execute multiple threads simultaneously. These typically have two or more threads that actively compete for execution time within a kernel and when one thread is stopped, the processing kernel starts executing another thread.

The context changes between these subprocesses very quickly and gives the impression that the computer is running the processes in parallel, which gives us the ability to multitask.