What is the difference between a process and a thread?

Source: Internet
Author: User
Durian Art Sound
Links: https://www.zhihu.com/question/21535820/answer/22915780
Source: Know
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

First, on the process and the thread, the definition is different from the understanding

1. What is the process?
is a program with a certain independent function, it is a system of resource allocation and scheduling of an independent unit, focusing on system scheduling and individual units, that is, the process is a program that can run independently.
2. What is a thread?
An entity of the thread process, which is the basic unit of CPU scheduling and dispatch, is a smaller unit that can run independently than the process itself, and the thread does not own system resources at all.
At run time, just take up some counters, registers, and stacks.

Ii. the relationship between them

1. A thread can belong to only one process, while a process may have multiple threads, but at least one thread (usually the main thread).
2. The resource is allocated to the process, and all the threads of the same process share all the resources of the process.
3, the thread in the execution process, the need for collaboration synchronization. Synchronization is achieved between threads of different processes using the means of message communication.
4, the processor to the thread, that is, the actual processing machine running is a thread.
5. A thread is an execution unit within a process and a scheduled entity within a process.

Three, from three angles to analyze the difference between the two
1, scheduling: The thread as the basic unit of dispatch and allocation, the process as the basic unit of resources.
2, Concurrency: Not only the process can be executed concurrently, the same process can be executed concurrently between multiple threads.
3. Owning a resource: a process is an independent unit that owns resources, and threads do not own system resources, but can access resources that belong to the process.

What is the difference between a process and a thread?

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.