What is the difference between a process and a thread?

Source: Internet
Author: User
Concept:
Process: One ProgramDynamic execution of a dataset is the basic unit for resource allocation.
Thread: the basic scheduling unit in a process.
The division scale of threads is smaller than that of processes. A process contains one or more threads.
From the execution process:
Process: it has independent memory units, and multiple threads share the memory, thus improving the running efficiency of the application.
Thread: each independent thread has a program running entry, sequence of execution, and program exit. But the thread cannot be executed independently. It must exist in the application and the application provides multiple thread execution control.
From a logic perspective: (important differences)
Multithreading means that multiple execution parts in an application can be executed simultaneously. However, the operating system does not view multiple threads as multiple independent applications to implement process scheduling, management, and resource allocation.

Another type:

A process is a program execution, and what is a thread? A thread can be understood as a program fragment executed in a process. The concept below a multitasking environment helps us understand the difference between the two.

Processes are independent, which is manifested in the memory space and Context Environment. threads run in the process space.

Generally, a process cannot break through the process boundary to access the storage space in other processes. Because the thread is in the storage space of the process, the threads produced by the same process share the same memory space.

Two segments in the same processCodeIt cannot be executed simultaneously unless a thread is introduced. A thread is a process. When a process exits, all threads generated by the process are forcibly exited and cleared. Threads consume less resources than processes. Both processes and threads can have priority.

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.