What is the difference between a process and a thread? When would you choose multiple processes over multiple threads?
Show hints
- Think about what each one owns: memory, files, registers, stack.
Show the explanation
Model answer. A process is a running program with its own address space and OS resources (open files, memory mappings). A thread is a unit of execution inside a process; threads of the same process share the address space and resources but each has its own registers, program counter and stack.
- Creation/switching: threads are cheaper to create and switch (no address-space change).
- Communication: threads share memory directly (fast, but needs locks to avoid data races); processes communicate through IPC (pipes, sockets, shared memory).
- Isolation: a crash or memory corruption in one thread can bring down the whole process; separate processes are isolated.
Choose processes when you need isolation or fault tolerance (a browser tab per process, worker processes that may crash) or to avoid a global interpreter lock (CPython multiprocessing). Choose threads for lightweight concurrency over shared data.
Follow-ups: context switch cost, race conditions, user vs kernel threads.
Original UniCircle question. Last reviewed 21 Oct 2026.
