April 27

GIF: Global Interpreter Lock

The essence is a mutex lock, which is placed on the interpreter. All threads in the same process need to grab the GIF lock before executing the interpreter code.

GIF: Pros: Guarantees thread-safety for Cpathon interpreter memory management.

Disadvantages: All threads in the same process can only have one execution at a time, that is, the multithreading of the Cpathon interpreter cannot achieve parallelism

 

Process pool and thread pool:

The pool is used to limit the number and limit the concurrent execution of tasks within the affordable range of the computer

Blocking: encounter IO blocking, deprive CPU resources

Non-blocking: No blocking is encountered. Even if IO operations are encountered by some means, it will not stay in place to perform other tasks and occupy CPU resources.

 

Synchronous and asynchronous are 2 ways to submit tasks

Synchronous call: After submitting the task, wait in place until the return value of the task is obtained after the task is completed, and then continue to execute the next line of code.

Asynchronous call: After submitting the task, instead of waiting in place, execute the next line of code directly

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325025665&siteId=291194637