Explain the difference between a Program, a Process, and a Thread.
Last updated
A program is passive code on disk, a process is that program in execution with its own resources, and a thread is the actual unit of execution running inside a process.
Program: A passive entity: an executable file (instructions and static data) stored on disk. It does nothing until loaded and run.
Process:
An active instance of a program with its own address space, open files, and OS-tracked state (via a PCB).
Processes are isolated from one another, so communication needs explicit IPC (pipes, shared memory, sockets).
Thread:
A lightweight unit of execution within a process: it has its own stack, registers, and program counter but shares code, heap, and files with sibling threads.
Because they share memory, threads communicate cheaply but risk race conditions without synchronization.
Relationship: one program can spawn many processes, and one process contains one or more threads.
- https://bytebytego.com/guides/what-is-the-difference-between-process-and-thread/
- https://blog.devgenius.io/program-process-and-thread-explained-in-one-minute-6016e4fdf4de
- https://learn.microsoft.com/en-us/windows/win32/procthread/processes-and-threads
- https://medium.com/@kaygeea/process-vs-thread-understanding-their-structural-differences-eb34a8175df0
- https://medium.com/@sesmiat/process-vs-thread-what-they-are-and-when-to-use-each-31405e0108a3
- https://medium.com/@no_man/what-is-a-thread-in-an-operating-system-88f31c92bd91
- https://www.geeksforgeeks.org/operating-systems/thread-in-operating-system/
- https://medium.com/@duhov/process-vs-program-vs-thread-what-every-developer-should-know-about-os-fundamentals-4a687a8a3cc9