A multi-task learning Python

1. Processes and Threads

A program is a process, the process is the smallest unit of the system for resource allocation system.

A process can have multiple threads (a program, such as QQ, comprising receiving information, send a plurality of function information, space, etc., the use of each function in the operation of the entire process QQ, will generate a new thread to execute operating)

 

2. Multitasking form

In the form of multitasking are: parallel, concurrent

Parallel: true multitasking, each thread is assigned to the core of independent, simultaneous threads running

Concurrency: fake multi-tasking operating system --- round-robin (some time loop is executed), multiple threads running on a single core, a thread running at the same time, the system constantly switching threads, looks like running at the same time, the actual the thread is constantly switching.

(Added: Generally, we run the computer program, mostly concurrent case, because the number of CPU cores is always less than the thread of execution, each core will handle multiple tasks)

 

3. threading.Thread the basic usage

 

 

Guess you like

Origin www.cnblogs.com/leafchen/p/11598030.html