Compare
Side-by-side on the decisions that recur: process vs thread, threads vs async, mutex vs semaphore, blocking vs non-blocking I/O, container vs VM — with when to choose each.
Process vs ThreadThreads vs Async / event loopConcurrency vs ParallelismMutex vs SemaphoreBlocking I/O vs Non-blocking / async I/Oselect / poll vs epoll / kqueueContainer vs Virtual machineStack vs HeapPipe vs Shared memoryOS page cache vs Application cache
| Process | Thread | |
|---|---|---|
| What it is | A running program: its own address space, descriptor table, PID, signal state | A flow of control inside a process: its own stack and registers, everything else shared |
| Memory | Private; sharing needs explicit IPC or shared memory | Shared heap and globals by default — fast, and the source of every data race |
| Creation cost | fork() copies page tables (copy-on-write), then usually exec; ~100 µs–1 ms | pthread_create / CreateThread: a stack and a kernel task; ~10–50 µs |
| Failure isolation | A segfault kills one process; the others keep running | One thread’s crash or corrupted heap takes the whole process down |
| Scheduling | A schedulable entity (on Linux, one task) | Also a schedulable entity — the kernel schedules threads, not processes (Linux: tasks; Windows: threads) |
| Communication | Pipes, sockets, shared memory, signals — all cross the kernel | A shared variable plus a mutex or an atomic — no kernel involved on the fast path |
| Runtime reality | Python multiprocessing, Node cluster, prefork servers | C++ std::thread, Java threads, Node worker threads, Python threads (GIL-limited for CPU work) |
| Choose this when | Isolation matters more than sharing: untrusted or crash-prone work, CPU-bound Python, separate security or resource limits per worker. | Workers must share large mutable state cheaply and you can discipline the locking: parallel C++/Java/Rust compute, pools inside one service. |