Deep dive
The choice impacts isolation, performance, and failure modes:
- Processes isolate memory; crashes don’t take siblings down.
- Threads are cheaper to create and context-switch, but share memory.
- IPC between processes is costlier than in-process synchronization.
- Security boundaries are easier with processes.
Examples
Web server model:
Many processes: safer isolation, higher memory
Many threads: less memory, more synchronization risk
Common pitfalls
- Assuming threads are always faster than processes.
- Sharing mutable state without proper synchronization.
- Using threads to get isolation (they don’t provide it).
Interview follow-ups
- When would you choose multi-process over multi-thread?
- How do you avoid shared-state bugs in threads?
- How does the OS schedule threads vs processes?