What is the difference between a process and a thread?
A process is an independent running program with its own memory space. A thread is a unit of execution inside a process, sharing that process's memory with its sibling threads.
What a process owns: its own virtual address space, file descriptors, and system resources. The operating system isolates processes from each other — one process cannot read another's memory without explicit inter-process communication. This isolation is the defining property.
What a thread owns: its own stack, program counter and registers. Everything else — the heap, global variables, open files — is shared with other threads in the same process.
The consequences of that difference:
Isolation and crash behaviour. A crashing process does not take others down. A crashing thread typically takes the entire process with it, because they share state.
Communication cost. Threads communicate by reading and writing shared memory, which is fast and immediate. Processes need pipes, sockets or shared memory segments, which are slower and require serialisation.
Creation cost. Threads are considerably cheaper to create and switch between, because there is no address space to set up or swap.
Safety. Shared memory is exactly why threads are hard. Two threads writing the same variable without synchronisation produce race conditions, and the resulting bugs are intermittent and notoriously difficult to reproduce. This is what mutexes, locks and atomics exist to prevent — and what deadlocks come from when used carelessly.
Where each fits. Processes suit isolation and fault tolerance — browsers run tabs as separate processes precisely so one page cannot crash or read another. Threads suit shared work within one application.
Language caveats matter. Python's Global Interpreter Lock historically prevented threads from executing bytecode in parallel, so CPU-bound Python work uses multiprocessing instead. Node.js is single-threaded for user code, handling concurrency through the event loop rather than threads.