c2cedge
CS Fundamentals · A — Operating Systems

Threads & Concurrency

Threads let one process do many things at once. The thread-vs-process distinction is one of the most-asked OS questions.

Test weight: Very highAsked by: All major recruitersDifficulty: Medium

A thread is the smallest unit of execution within a process. A process can contain many threads that share its memory (code, data, heap) but each have their own stack and registers. Threads make a program responsive and able to use multiple CPU cores.

Threads share, processes don't

Threads of the same process share the address space — so communication is cheap, but they can corrupt each other's data without care. Separate processes have isolated memory — safer, but heavier to create and to communicate between.

AspectProcessThread
Memoryown address spaceshares the process's memory
Creationheavylight
CommunicationIPC (slow)shared memory (fast)
Crash impactisolatedcan crash the whole process
Context switchexpensivecheaper
⚡ The edge
  • One line nails the comparison: processes are isolated, threads are shared. Threads are cheaper to create and switch, but a bug in one thread can bring down the whole process.
  • Concurrency is dealing with many tasks by interleaving them (one core, time-sliced); parallelism is actually running them at the same instant (multiple cores).
Worked example
'What is the difference between a thread and a process?'
  1. State the unit: a process is an independent program in execution; a thread is a lighter unit of execution inside a process.
  2. Give the key difference: threads of a process share memory; processes have separate address spaces.
  3. Add the trade-off: threads are faster to create and communicate, but less isolated — one bad thread can crash the process.
Worked example
'Explain concurrency vs parallelism.'
  1. Concurrency is structuring a program to handle multiple tasks that make progress by interleaving — possible even on one core.
  2. Parallelism is literally executing multiple tasks simultaneously, which needs multiple cores.
  3. Analogy: one cook switching between dishes is concurrency; two cooks each on a dish is parallelism.
⚠ Watch out
  • Don't say threads have separate memory — they share the process's address space (only stack/registers are per-thread).
  • Concurrency ≠ parallelism: you can have concurrency on a single core.
  • Shared memory between threads is the source of race conditions — which is why synchronization exists.
Practice this — take a timed mock →
1,300+ questions, scored, with a weak-area report.
Know who's ready. Not who finished.
HomeLibraryPrivacyTerms