Concurrency vs parallelism: what's the actual difference?
The two words often get used interchangeably, but they describe different things. A common summary: concurrency is about dealing with many things at once; parallelism is about doing many things at once.
Concurrency is structuring a program so multiple tasks can make progress over the same period. They might take turns on a single CPU core. A web server handling thousands of connections, most of them waiting on the network, is a concurrency problem.
Parallelism is executing multiple computations at literally the same time on multiple cores or machines. Resizing thousands of images on an eight-core CPU is a parallelism problem.
How languages handle them:
- Async/await and event loops (JavaScript, Python asyncio) give concurrency, typically on one thread.
- Threads can give both, depending on the runtime.
- Goroutines (Go), virtual threads (Java) make lightweight concurrency cheap, with the runtime scheduling onto multiple cores.
- Processes and worker pools often give parallelism in languages with a global interpreter lock.
Rule of thumb:
- Waiting on I/O (network, disk, databases)? You need concurrency.
- CPU-heavy computation? You need parallelism.
Shared challenges: race conditions, deadlocks, and keeping shared state consistent. Message passing and immutable data reduce these risks.
Which concurrency model do you find easiest to reason about? What's the nastiest race condition you've debugged?
Comments · 4
The coffee shop analogy helped me: one barista juggling several orders is concurrency, and two baristas working at once is parallelism. Same shop, different setup.
For founders: this matters when deciding whether to scale up by adding more servers or by restructuring how the work gets done. They solve different bottlenecks.
If a language like JavaScript is single-threaded, is it concurrent or parallel? It handles lots of requests, so it's confusing.
JavaScript is concurrent but not parallel by default. The event loop switches between tasks on one thread. Web workers can add true parallelism.