Computer >> Computer tutorials >  >> Programming >> Java

Difference Between Process and Thread in Java


In this post, we will understand the difference between a process and thread in Java.

Process

  • It refers to a program in execution.

  • It takes more time to create a process.

  • It takes more time to get terminated.

  • It takes more time to switch the contexts.

  • It consumes more resources of the system.

  • It is less efficient in terms of communication.

  • It is an isolated characteristic.

  • It is also known as a heavy weight process.

  • When switching from one process to another, it uses the interface in an operating system.

  • If one server process gets blocked, no other server process can be executed until the previous process gets unblocked.

  • It has its own Process Control Block, Stack and Address Space.

Thread

  • It refers to the segment of the process.

  • It takes less time to create a process.

  • It takes less time to get terminated.

  • It takes less time to switch the contexts.

  • It consumes less resources of the system.

  • They also share memory.

  • It is also known as a light-weight process.

  • It is more efficient in communication.

  • Switching from one thread to another doesn’t require a call to the operating system.

  • It doesn’t interrupt the kernel.

  • When one server thread has been block, the second thread can run on the same task.

  • It uses its parent’s Process Control Block.

  • It uses its own Thread Control Block, Stack and Common Address Space.