Python---Fundamentals review (10) Processes and threads

Source: Internet
Author: User
Foreplay: The concept of processes and threads

If you learn Linux under the process, thread, signal ... will have a deeper understanding. So the recommendation to learn, including network programming can be understood, especially for Select,pool,epool will have more understanding.

A process is the smallest unit of resource management, and a thread is the smallest unit of program execution. A program can have multiple processes, and a process can have multiple threads executing concurrently

1. Process:

The operating system isolates the address space that each process can access. If you need to pass information between processes. Then you can use interprocess communication or other way, like signal, file, database, clipboard .... such as In a process's schedule, the event that the process needs to switch is much more. In order to better support information sharing and reduce switching overhead. Thus the threads evolved from the process.

2. Threads:

A thread is the execution unit of a process. For most programs, there may be only one main thread, which is the program process. In the system, it seems that all the threads are executed concurrently, in fact, to collectively seize the resources, when a thread is finished, the next use immediately, reducing the gap in time. is roughly the same as the process preemption time slice. But it still improves a lot of efficiency.

Example: When downloading a file, you can split the file into multiple parts and then use multiple threads to download at the same time, speeding up the download speed.

3. Comparison of process threads:

Python---Fundamentals review (10) Processes and threads

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.