The core difference is memory sharing. A process owns a private address space. Threads live inside one process and share that space, including the heap and global data.
Because threads share memory, they can pass data by reading and writing the same variables. Two processes cannot, so they need pipes, sockets or shared-memory setups. Each thread still gets its own stack and registers, so it can run its own function calls independently.
The tradeoff is safety versus speed. Shared memory makes thread communication fast but risky, since one thread's bad write can corrupt another's data. Separate processes stay isolated, so a crash in one usually leaves the others running. Pick threads for tight cooperation and processes for isolation.
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Process A runs two threads. Each has its own stack and registers, but both share one counter. Processes B and C keep one counter each.
Thread 1 writes*p = 7; // thread 1
Stacks
thread 1: p1
thread 2: p1
process B: p2
process C: p3
Heap + globals
1process A
counterchanged7
2process B
counter0
3process C
counter0
Both threads use one counter, so thread 2 reads 7 too. A bad write reaches thread 2 the same way.
Process B writes*p = 9; // process B
Stacks
thread 1: p1
thread 2: p1
process B: p2
process C: p3
Heap + globals
1process A
counter7
2process B
counterchanged9
3process C
counter0
The 9 stays inside process B, so process C still reads 0. Sharing it takes a pipe, a socket or shared memory.
1step
Before any write: Process A runs two threads. Each has its own stack and registers, but both share one counter. Processes B and C keep one counter each.
1 / 3← → keys
Threads have separate stacks but share the heap, so one write reaches both. Processes keep private memory and share data through a pipe, a socket or shared memory.
Two threads each increment a shared counter a million times. Why can the total come out short?Name the race. Read-modify-write on the counter isn't atomic, so updates get lost. Fix it with a mutex or an atomic increment.
Is switching between two threads of one process cheaper than switching between two processes?Same address space, so the page tables stay put and cached translations stay valid. Registers and the stack pointer still get swapped.
If processes don't share memory, how do they exchange data?Name pipes, sockets and shared memory, and say which ones copy data through the kernel and which one needs setup and its own locking.
What you can say
The core difference is that a process owns a private address space, while threads inside one process share that space.
That shared space includes the heap and global data, so threads can pass data just by reading and writing the same variables.
Each thread still gets its own stack and registers, which is what lets it run its own function calls independently.
Two processes can't see each other's memory, so they talk through pipes, sockets or a shared-memory region they set up on purpose.
The tradeoff is speed versus safety, because one thread's bad write can corrupt another's data, while a crashed process usually leaves the others running.
So I'd pick threads when the work needs tight cooperation, and processes when I need isolation.
Weak answers to avoid
Says "a thread is a lightweight process" and stopsThat's a slogan, not a difference. Say what threads share, the heap and globals, and what each one keeps for itself, its stack and registers.
Thinks threads share their stacks tooEach thread gets its own stack and registers, and that's how it runs its own call chain. Leaving it out suggests you don't know how threads execute.
Calls threads strictly better because they're fasterShared memory means one bad write can corrupt everyone's data. Name that cost and say when you'd use processes for isolation.
Never says how processes communicateOnce you say processes don't share memory, the interviewer expects to hear how data gets between them. Name pipes, sockets or shared memory.
Interview lens
Likely follow-ups, what you can say, and the weak answers to avoid.