Definition and differences of processes and threads

Source: Internet
Author: User

What is a process and what is a thread

System to do one thing, run a task, all running tasks are usually a program;

Each running program is a process, which can be seen visually on the task manager.

When a program runs, the interior may contain multiple sequential execution flows, and each sequential execution flow is a thread.


About the characteristics of a process

Independence: A process is an entity that exists independently in the system and can have its own independent resources, each of which has its own private address space. The content cannot be accessed without running through the process itself.

Dynamic: The difference between a process and a program is that the program is static and the process is dynamic. A program is just a static set of instructions, and a process is a collection of instructions that are running in the system. With the concept of time, such as the life cycle;

Concurrency: Between processes, alternately executed.


threads, a sequential execution flow;

It is part of the process and a process can have multiple threads.


About the characteristics of a thread, or its advantages

1, the process can not share memory between the single-threaded shared memory is very easy

2. The system creation process needs to reallocate system resources for the process, but the cost of creating threads is minimal. Therefore multi-tasking is more efficient than multi-process implementation concurrency.

3, the Java language built-in multi-threaded function support, rather than simply as the underlying operating system scheduling mode


Summarize:

A program runs at least one process, and a process contains at least one thread, and the thread is part of the process.

Line threads for the process, is very strong, to achieve the sharing of resources, the loss of resources, artificial manual control procedures for the operation.

Definition and differences of processes and threads

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.