01 · Why it’s true
A process is a running program with its own private memory and its own set of open files and sockets. The operating system keeps processes isolated, so one crashing or corrupting its memory doesn’t affect another.
Threads are separate paths of execution inside one process. They share the heap, global variables, and open files; each has only its own stack and registers. Sharing makes communication cheap, but it also means one misbehaving thread can corrupt data — or crash the process — for all the others.
02 · Picture it
03 · In the interview
- Choosing between worker processes and threads: isolation versus efficiency.
- Explaining why one bad thread can take down a whole service.
- Seeing threads in tools:
top -H,ps -L, or/proc/<pid>/task.
04 · Practice question
“When would you run several worker processes instead of one process with many threads?”
A strong answer covers
- Processes isolate failures: a crash or leak in one worker doesn’t take down the rest, and each can be restarted on its own.
- Threads are cheaper and share memory directly, which suits work that needs shared state or a shared cache.
- Some runtimes limit parallel execution of threads within a process (for example, CPython’s global interpreter lock in its default build), which pushes CPU-bound work toward processes.
- Trade-off: processes use more memory and need explicit communication.