Skip to content

1. Process vs Thread

Process — a program in execution, with its own isolated memory space, resources, and state. Each process gets its own code, data, heap, and stack; its own file descriptors, registers, and PC; and isolation from other processes (one crash doesn't crash others).

Thread — a unit of execution within a process — lightweight, shares the parent process's memory. Each thread has its own stack + registers + PC, but shares the heap, code segment, global data, and file descriptors with its sibling threads.

Aspect Process Thread
MemorySeparate address spaceShared address space
Creation costHeavy (fork/exec)Light
CommunicationIPC (pipes, sockets, shared mem)Direct (shared memory)
IsolationStrong — crash is containedWeak — one bad thread can kill all
Context switchExpensiveCheap
ExampleChrome tabs (separate processes)Chrome's JS engine threads

Why it matters: processes give you isolation (browser tabs, microservices); threads give you parallelism with shared data (web server handling requests, a game engine's physics + rendering).

Analogy: a process is a factory — its own building, equipment, workers. A thread is a worker inside that factory — workers share the floor and tools but each does their own task.