python-concurrency Parallel, synchronous asynchronous, synchronous lock

Source: Internet
Author: User

Concurrency: The system has the ability to handle multiple tasks (actions)

Parallelism: The system has the ability to simultaneously handle multiple tasks (actions)

Synchronization: When the process executes to an IO (waiting for external data), it waits, waits, synchronizes

Async: When a process executes to an IO (waiting for external data), it does not need to wait until the data is received successfully and then comes back to processing.

GIL: Global explanation Lock: No matter how many threads you have, how many cpu,python you have in the execution will only allow one thread to run at the same time. (Interpreter level protection process security)

Gil's role: At the same time, only one thread is executed by the CPU, resulting in single-threaded run results, and multicore is not available.

Garbage collection mechanism: a thread of the interpreter is being garbage collected.

CPU switchover: IO Blocking, CPU Execution time window, etc.

Threads are competing for CPU resources to get executed.

tasks: IO-intensive (multiple IO interactions, more CPU idle time), compute-intensive (), time.sleep () equivalent to IO operations

For IO-intensive tasks, Python's multithreading is meaningful, and computational-intensive tasks, Python's multithreading is not applicable, you can use multi-process.

Sync Lock: Thread is set to Serial, Lock=threading.lock (), Lock.acquire (), Lock.release ()

python-concurrency Parallel, synchronous asynchronous, synchronous lock

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.