Python high-performance programming--001--threads and processes basic concepts

Source: Internet
Author: User
I. What is a process
A process is a single execution of a program, and a program is a binary and other type of data that is executable on disk.
The life cycle of a process: The program is read into memory, and its life cycle starts only when it is called by the operating system.
Each process has its own address space, memory, data stack, and other records of its running track of the auxiliary data, each process has its own memory space, data stack, etc., so the process can not directly share information, can only use interprocess communication.

Second, what is a thread
All threads run in the same process and share the same running environment. You can think of a thread as a "mini process" that runs in parallel in "main process" or "main thread".
Line threads start, sequence execution, and end three parts.
The sharing of the same piece of data space between threads in a process means that it is easier to share data and communicate with each other between threads.
?? Note that threads are generally run concurrently, but in a single CPU system, there is no real concurrency, because only one thread is using CPU resources at a time.

Iii. Summary
Each process has its own data space, so the inter-process communication and data sharing will be more complex;
Threads share the same runtime environment and share the same piece of data space, and data sharing and inter-thread communication are relatively straightforward.
In I/O intensive operation, multi-process and multi-threaded operation efficiency is relatively small;
In CPU-intensive operation, multi-process operation efficiency is higher than multithreading efficiency;

Python high-performance programming--001--threads and processes basic concepts

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.