Question

What is the difference between concurrency and parallelism?

Vault Verified
Curated Intelligence
Definitive Source
Answer

Concurrency is about structure; parallelism is about execution. A concurrent program is composed of tasks that can make progress independently; a parallel program actually runs them at the same instant. A system can be concurrent without being parallel, and the distinction determines which problems each solves.

The single-core illustration. One processor core running an operating system with many programs is concurrent and not parallel — tasks are interleaved rapidly, each making progress, with only one executing at any instant.

What each is for:

Concurrency handles waiting. Most programs spend their time blocked on network calls, disk reads, database queries and user input. Concurrency lets other work proceed during that wait. It is the right tool for input/output-bound work, and it improves throughput without needing more cores.

Parallelism handles computation. Splitting a calculation across cores makes it finish sooner. It is the right tool for CPU-bound work, and it requires genuine hardware parallelism to help at all.

Using the wrong one is a common mistake. Adding threads to a CPU-bound task on a single core achieves nothing but overhead; using parallelism for network calls wastes cores that will only sit blocked.

The mechanisms: threads, which the operating system schedules pre-emptively; async and await with an event loop, which is cooperative and much cheaper per task, allowing very large numbers of concurrent operations; processes, which are isolated and heavier; and coroutines and lightweight threads in some runtimes.

Why concurrency is hard. Shared mutable state. Race conditions, deadlocks and subtle ordering bugs are difficult to reproduce and to reason about. The mitigations are not sharing state — message passing and immutability — or disciplined locking.

A specific point about interpreted languages. Some runtimes have a global lock permitting only one thread to execute bytecode at a time, so threads provide concurrency and not parallelism for pure computation — which is why separate processes are used for CPU-bound work there.

Related Questions