Difference between process and thread in java


In this tutorial, we are going to see differences between process and thread in java.
If you are working on multithreading in java, it is good to know differences between process and thread. How multithreading can improve performance by executing code in parallel.

Process vs Thread:

  • The process can be referred as program in execution whereas thread is part of process.
  • Process has its own address space whereas multiple threads share same address space of process. Each thread has its own stack.
  • Process can have multiple threads but thread is the smallest unit which can execute concurrently with other threads.
  • Process are quite heavyweight and have more overhead whereas thread is light weight and have less overhead.
  • Process do not depend on each other whereas threads are not independent as they share address space.
  • You do not require synchronization in case of process. Threads require synchronization to avoid unexpected scenarios.
  • Processes can communicate to each other using inter-process communication only where as thread can communicate directly as thread share same address space.
  • You can easily create new threads by calling thread’s start method but you need to copy resources of parent process to create a new child process.

Add Comment