What is the difference between a process and a thread?
Quick Answer
A process is an isolated running program with its own virtual address space; the OS protects one process's memory from another. A thread is a unit of execution within a process; all threads in a process share the same memory, so communication is cheap but you need synchronization to avoid data races.
A process is an instance of a program with its own memory space that the OS keeps isolated from every other process. A thread is a path of execution inside a process, and all the threads in one process share that process's memory. So threads are cheaper to create and can talk to each other just by touching shared objects, but that's exactly why you need locks — two threads writing the same field is a race. Processes are isolated so they're more robust, a crash is contained, but they have to communicate through IPC. In .NET I almost never touch raw threads; I use Task and the thread pool.
- Processes: strong isolation, a crash in one doesn't take down others, communication needs IPC (pipes, sockets, shared memory).
- Threads: lightweight, shared heap, but shared mutable state means locks, and one thread corrupting memory can crash the whole process.
- .NET adds abstractions on top: the thread pool,
Task, andasync/await— you rarely create raw threads.