The difference between a JAVA process and a thread __java

Source: Internet
Author: User

what is a process and what is a thread

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

Each running program is a process that can be seen visually in the task Manager.

When a program is running, the interior may contain multiple sequential execution flows, each of which is a thread.


about the characteristics of the process

Independence: A process is an independent entity in a system that can have its own independent resources, each with its own private address space. The content cannot be accessed without the process itself running.

Dynamic: The difference between process and 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 running in the system. Have the concept of time, such as the life cycle;

Concurrency: Between processes, alternately executed.


Thread, a sequential execution stream;

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


about the characteristics of the thread, or its advantages

1, the process can not share memory, the single thread 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 very small. Therefore, multi-threading implementation of multitasking is more efficient than concurrent implementation of multiple processes

3, the Java language built-in multi-threaded feature support, rather than simply as the underlying operating system of the scheduling method


Summary:

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

Line threads relative for the process, it is very powerful, to achieve the sharing of resources, the loss of resources to reduce the artificial manual control program operation.


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.