Processes Vs Threads - Explained with Analogy

Processes Vs Threads - Explained with Analogy

What is a Process?

A process is a collection of operating-system states that includes file-system handles, graphical windows, network sockets, and at least one thread of execution.

What is a Thread?

A thread is a unit of work that refers to a program image and a memory space.

When an operating system starts a new process, it begins by running a single thread of execution in a program. The program may then decide to create additional execution threads. All the threads, when created, share access to the same set of process states. If a program creates a new process, the threads that run the new process program do not have access to the original program’s process state.

What is deadlock?

Deadlock describes a condition in which two or more threads are blocked (hung) forever because they are waiting for each other. There are many causes of deadlocks. The Thread Analyzer detects deadlocks that are caused by the inappropriate use of mutual exclusion locks.


Think of processes as a pipeline system for your house. A pipeline system will have a water tank( memory, files etc) which will distribute water to your kitchen, bathroom.. etc (threads). Now if some stupid (thread) decides to take an afternoon shower in the bathroom. You will face water scarcity for your kitchen purpose. Hence, creating a deadlock.

For creating a new Process, You would have to buy a new water tank ( allocate memory, etc) and buy a new water motor, which is more costly than adding a new pipeline to a kitchen for the same water tank.

Real-life example:

  1. When you are running multiple apps on your Android devices, you have created multiple Processes for each one of them.

  2. You can create a multi-threaded server for serving data to multiple clients.

Process ⇒ Multiple Threads ⇒ Locking ⇒ Data is not modified by two threads simultaneously.



  2. describes a condition in,use of mutual exclusion locks.

Fri May 05 2023 10:24:09 GMT+0000 (Coordinated Universal Time)