# Process vs Program vs Thread

> A program is passive code on disk, a process is that program executing in memory with its own isolated address space, and a thread is a lightweight unit of execution inside a process. Threads in one process share its heap and global data but each has its own stack and registers, while separate processes cannot access each other's memory.

Canonical: https://devsunite.com/resources/core-subjects/operating-systems/process-vs-program-vs-threads
Last updated: 2026-11-22

Subject: Operating Systems · Category: Process Management · 4 min read

These three terms get used loosely in casual conversation, but they mean genuinely different things, and the distinction between a process and a thread specifically comes up constantly in real systems design.

## The three, precisely defined

A **program** is a passive file on disk: compiled code and data, not running, not occupying memory beyond what it takes to store the file itself.

A **process** is a program actually loaded into memory and executing, with its own independent, isolated address space, its own heap, its own stack, tracked separately by the OS. Two processes cannot directly read or write each other's memory.

A **thread** is a unit of execution that lives inside a process. A process always has at least one thread, and can have many. All threads within the same process share that process's memory (its heap and global data), but each thread still gets its own separate stack and its own set of CPU register values, so each thread can be independently scheduled and can be doing different work at the same time.

## Why threads exist at all

If two processes need to cooperate, they can only share data through OS-provided inter-process communication mechanisms (pipes, shared memory segments, sockets), since their memory is otherwise isolated by design. Threads within one process skip all of that: because they already share memory directly, two threads can read and write the same variables with no IPC mechanism needed at all. This makes threads much lighter weight to create and much faster for cooperating tasks to communicate through, at the real cost that a bug in one thread (corrupting shared memory) can affect every other thread in that same process, since there's no memory isolation between them the way there is between processes.

## A concrete example

A web browser is a real process, or more precisely today, often several cooperating processes (many browsers isolate each tab as its own process specifically to prevent one tab's crash or memory corruption from taking down the whole browser). Inside a single browser process, though, multiple threads commonly run at once: one thread handling the user interface and staying responsive to clicks, another thread downloading a file in the background, another thread decoding video. All of them share that process's memory (so the download thread can hand decoded data directly to the UI thread with no IPC needed), but each one has its own execution stack and can be scheduled onto a CPU core independently of the others.

## Where this matters in real systems

Modern multi-core CPUs make this distinction very practical: a program with multiple threads can genuinely run different threads on different CPU cores simultaneously, which is exactly how a video editor can decode video on one core while rendering the UI responsively on another, all within one process's shared memory. Server software handling many simultaneous client connections commonly uses a thread (or a lightweight equivalent) per connection specifically because threads are far cheaper to create and switch between than full separate processes would be for the same job.

## What interviewers actually ask about processes vs threads

- **"What's the key difference between a process and a thread?"** Processes have fully isolated memory from each other; threads within the same process share that process's memory, only getting their own separate stack and register state.
- **"Why are threads considered 'lighter weight' than processes?"** Creating a thread doesn't require setting up a whole new isolated address space the way creating a process does, and threads can communicate through shared memory directly instead of needing OS-level IPC.
- **"What's the downside of threads sharing memory?"** A bug in one thread, especially a race condition or memory corruption, can affect every other thread in that same process, since there's no memory isolation between them.
- **"Can two threads in the same process run on different CPU cores at the same time?"** Yes, on a multi-core system, threads from the same process can genuinely execute in parallel on different cores, since each thread has independent register state and can be scheduled separately.

## Key takeaways

- A program is static code on disk; a process is that program running with isolated memory; a thread is a unit of execution inside a process.
- Threads in the same process share memory directly, each only getting its own stack and register state.
- Shared memory makes threads lighter weight and faster to communicate between, at the cost of no isolation between them.
- Modern multi-core CPUs let multiple threads from one process genuinely execute in parallel on different cores.

## Related

- [Previous: Processes in an Operating System](https://devsunite.com/resources/core-subjects/operating-systems/processes-in-os)
- [Next: Process Control Block (PCB)](https://devsunite.com/resources/core-subjects/operating-systems/process-control-block-pcb)
- [More in Process Management: Context Switching](https://devsunite.com/resources/core-subjects/operating-systems/context-switching)
- [More in Process Management: CPU-Bound vs I/O-Bound Processes](https://devsunite.com/resources/core-subjects/operating-systems/cpu-bound-vs-io-bound-process)
- [More in Process Management: IPC and Pipes](https://devsunite.com/resources/core-subjects/operating-systems/ipc-and-pipes)
- [More in Process Management: Zombie vs Orphan Process](https://devsunite.com/resources/core-subjects/operating-systems/zombie-vs-orphan-process)
- [More in Process Management: Important Terms Related to Processes](https://devsunite.com/resources/core-subjects/operating-systems/important-terms-related-to-process)
- [All 205 OS interview questions](https://devsunite.com/resources/core-subjects/operating-systems)
