what makes a thread different from a process in java ?

Major differences between a thread and a process in java ? The below given are the important differences between a thread and a process in java. 

Thread Definition: The lowest and lightest processing unit that a scheduler can control independently is a thread. Threads are components of a process that only enable the concurrent, efficient execution of programs with other components or threads of the process. The simplest approach to complete challenging tasks is by using threads. It is thought to be the simplest method for utilizing a machine’s numerous CPUs. They are separate from one another yet share the same address space.

Process Definition :  A process is merely refers to an active programs, or one that is now running.  A process can have multiple threads by dividing the problems into smaller modules for execution.

Differences between a thread and a process in java ?

Thread in Java Process in java 
A thread is a subunit or segment of a process.A process is a program in execution containing multiple threads.
Inter-thread communication is faster, less expensive, easy and efficient because threads share the same memory address of the process they belong to.  Inter-process communication is slower, expensive, and complex because each process has different memory space or address.,
 Processes with multiple threads requires less resources.Processes without threads requires more resources.
Threads requires less time for creationA process requires more time for creation
Threads requires less time for terminationA process requires more time for termination
Threads requires less time for context switchingA process requires more time for context switching
Threads provide better communicationA process provides less effective communication
Threads are parts of a process, so they are dependent on each other but each thread executes independently.Processes are independent of each other.
There is a need for synchronization in threads to avoid unexpected scenarios or problems.There is no need for synchronization in each process.
They share data and information with each other. They do not share data with each other. 
Differences between a thread and a process in java

Leave a Reply

Your email address will not be published. Required fields are marked *

*