Operating Systems

Process vs Thread

Process vs thread explained for interviews. How memory is shared, why threads are lighter, and what happens when one crashes.

Process
Operating System Process
VS
Thread
Thread of Execution
The short answer

A process is an independent running program with its own memory space. A thread is a lighter unit of execution that runs inside a process and shares that memory with other threads in the same process.

Process vs Thread at a glance

ProcessThread
MemoryOwn isolated memory spaceShares memory with other threads in the process
Creation costExpensive, OS allocates a new memory spaceCheap, reuses the parent process memory
CommunicationNeeds IPC, pipes, sockets, or shared memoryDirect, since memory is already shared
Crash impactA crash does not affect other processesA crash can take down the whole process
Context switchSlower, full memory context changesFaster, only registers and stack change
ExampleTwo separate browser tabs in some browsersMultiple tabs handled by one browser process

When to use each

Choose Process when

  • You need strong isolation so one crashing task cannot bring down another.
  • You are running unrelated programs that should not share memory.
  • You want the operating system to manage security boundaries for you.

Choose Thread when

  • You need multiple tasks to share data quickly without copying it.
  • You want lower overhead when spinning up many concurrent tasks.
  • You are building a responsive UI that keeps working while a background task runs.

The memory picture

Every process gets its own virtual address space from the operating system. Nothing in one process can accidentally touch another process's memory unless it goes through an explicit channel. Threads live inside a process and share that same address space, which is exactly why they are fast to create and fast to communicate through, but also why one misbehaving thread can corrupt data another thread depends on.

Why threads exist at all

If isolation is safer, the reason threads exist is speed. Creating a full process is expensive because the OS has to set up a new memory space. If you just want several pieces of work to run at the same time inside one program, like handling multiple web requests, threads let you do that without paying the full process cost each time.

In the interview

If asked why threads need synchronisation and processes usually do not, the answer is shared memory. Threads can read and write the same variables at the same time, which is exactly what locks and mutexes exist to control.

Frequently asked questions

Is a thread always faster than a process?

Creating and switching between threads is generally faster than doing the same with processes, because threads avoid the overhead of setting up a new memory space.

What is a race condition?

A race condition happens when two threads read and write shared memory at the same time without proper synchronisation, producing unpredictable results depending on timing.

Does every process have at least one thread?

Yes. Every process starts with a main thread. Additional threads can be created inside that same process if the program needs concurrency.

Want more interview ready comparisons?

Browse every Process vs Thread style breakdown, or explore the full question library.

All comparisons Browse questions