Threads inside the same process share most things. What does each thread get its own copy of?
Its own stack; threads share the process's global memory and heap.
- Its own heap
- Its own stack ✔
- Its own process ID
Why: Threads in one process share the same global data and heap, which makes sharing fast but risky. Each thread has its own stack for local variables and function calls. Separate processes, by contrast, do not share memory by default.
Huh, didn't know that: On Linux with POSIX threads, all threads in a process also share one process ID.
Why did the two threads fight? They both wanted the last cookie in the shared heap.
References
Answer: Its own stack. Threads in one process share the same global data and heap, which makes sharing fast but risky. Each thread has its own stack for local variables and function calls. Separate processes, by contrast, do not share memory by default.
- Linux man-pages: pthreads(7) man7.org/linux/man-pages/man7/pthreads.7.html
These threads share the same global memory (data and heap segments), but each thread has its own stack (automatic variables).
Checked 2026-10-10.
Think this answer is wrong? Tap "Challenge this answer" on the card in the game and tell us why.
More stuff everyone should know
That's stuff everyone should know.