Threads & asyncBeginner

Concurrency vs parallelism

“What is the difference between concurrency and parallelism? Can you have one without the other, and why does the distinction matter for bugs?”

What this tests

  • Concurrency as structure (many things in progress) vs parallelism as execution (many things at once)
  • Single-core concurrency through time slicing; an event loop as concurrency without parallelism
  • That race conditions come from concurrency, not from parallelism
  • Runtime specifics: GIL, V8, real OS threads

Answers by level

Read the beginner answer first and notice what is missing.

Concurrency is about structure: a program has several tasks *in progress* whose steps can interleave — a request being parsed while another waits for the database. Parallelism is about execution: several instruction streams running *simultaneously* on separate cores. A single core gives you concurrency without parallelism by time-slicing; the tasks make progress in turns (Concurrency versus Parallelism).

Each exists without the other. An event loop is concurrent and not parallel: thousands of connections in flight, one thread executing. A SIMD instruction adding eight floats, or a GPU kernel, is parallel without being concurrent in the program-structure sense. Multi-threading on multiple cores is both.

The distinction decides where speedups come from. If a task is I/O-bound, concurrency alone helps — the waiting overlaps — and parallelism adds nothing because the CPU was idle anyway. If it is CPU-bound, only parallelism helps, and only the parallelisable fraction speeds up (Amdahl’s law); the serial 10% caps you at 10× no matter how many cores.

And it decides where bugs come from: race conditions are a property of concurrency. Two threads incrementing a counter can lose an update on a single core if the scheduler preempts between load and store. You do not need two cores to have a race; you need two interleavable tasks and shared state (Race Conditions). Parallelism adds a second class of problems — memory visibility and reordering across cores — on top.

Green flags · Red flags

Strong green flag · Distinguishes data race from race condition and knows JavaScript can have the latter.
Green flags
  • Defines the two in different words: structure vs simultaneous execution
  • Gives an example of each without the other
  • States that races need only interleaving, not multiple cores
  • Connects I/O-bound vs CPU-bound to which one helps
Red flags
  • Uses the two terms interchangeably
  • Believes a single-threaded program cannot have race conditions
  • "More threads always means faster"

Follow-up questions

F1
A Node.js service handles 5,000 concurrent websockets on one thread. Parallel?
F2
Where can a race happen in single-threaded JavaScript?
F3
Why do 16 CPU-bound Python threads use one core?

Scenario

A team rewrote a CPU-heavy report generator from synchronous to async/await in Python expecting it to get faster. It did not. Explain to them what changed and what would actually help.

Learn this topic