What is a thread and what is the difference between a thread and a process?

Source: Internet
Author: User

A thread is sometimes called a lightweight process, which is a smaller unit of activity than a process, and it is an execution path in the process. A process can have multiple execution paths that are threads.

The main differences between threads and processes:

1. A thread is an integral part of a process, a process can have multiple threads, and at least one thread can execute.

2, the process is the basic unit of resource allocation, he has his own address space and a variety of resources. A thread is the basic unit of a processor's dispatch, and he can only share the resources of a process with other threads, without any resources of its own.

3. Multiple threads of a process are active in the address space of the process.

4, the thread and the process, all have their own state and the corresponding synchronization mechanism. However, because the thread does not have its own separate program and data space, it cannot be exchanged to the outer village like the program and data of the process.

5. Because threads within the same process share memory and files. So they communicate with each other without calling the kernel.

6, the process of scheduling and control is mostly done by the operating system kernel, and the control of the thread can be done by the operating system kernel, or by the user control.

What is a thread and what is the difference between a thread and a process?

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.