1.

Process vs Thread in Java

Answer»

The terms process and thread are often used in multithreading in Java. A major difference between a process and a thread is that a process is a program that is currently executing while a thread is a subpart of the process.

The differences between a process and a thread in detail are given as follows:

Process
Thread
A process is a program that is currently executing.
A thread is a subpart of the process.
A process is also KNOWN as a heavyweight task.
A thread is also known as a lightweight task.
Communication between TWO processes is quite complicated and expensive.
Communication between two threads is comparatively less expensive.
All the processes have a separate address space as they are individual entities.
The threads of a single process share the address space of the process as they are a PART of the process.
Context switching between two processes is quite expensive.
Context switching between two threads is less expensive than that between processes.
An individual process has its own global variables, address space, files, accounting information etc.
A thread has its own stack, register and program counter. The rest of the components are shared by all the threads of a process.
A computer SYSTEM can run multiple processes concurrently in process multitasking.
A computer system can run multiple threads of a program concurrently in thread multitasking.
Java does not CONTROL process multitasking.
Java does controls thread multitasking.


Discussion

No Comment Found