Python path--python basic 12--concurrent Programming

Source: Internet
Author: User
I. Introduction of the Association Process

  The topic in this section is to implement concurrency based on a single thread, that is, to implement concurrency with only one main course (obviously the only CPU available), so we need to look back at the nature of Concurrency: toggle + save State . The CPU is running a task that, in both cases, will be cut off to perform other tasks (the switchover is controlled by the operating system), one case is that the task is blocked, and the other is that the task has taken too long to calculate or has a higher priority program to replace it.

PS: When introducing the process theory, the three execution states of the process are mentioned, and the thread is the execution unit, so it can also be understood as the three states of the thread

One: The second situation does not improve efficiency, just to allow the CPU to rain equitably, to achieve the seemingly all tasks are "simultaneous" effect, if more than one task is pure calculation, this switch will reduce efficiency. For this we can verify based on yield. Yield itself is a way to save the running state of a task in a single thread, so let's review it briefly:

Python path--python basic 12--concurrent Programming

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.