Concurrency vs Parallelism
Define concurrency and parallelism precisely, and explain the relationship between them. Give one concrete example where a system is concurrent but not parallel.
Concurrency is dealing with many tasks at once by interleaving them — tasks take turns making progress on a shared resource. It is about how work is structured.
Parallelism is doing many tasks at once by executing them literally simultaneously on separate CPU cores. It is about how work is executed.
Relationship: all parallelism is a form of concurrency, but not all concurrency is parallelism. Parallelism requires multiple cores; concurrency does not.
Concurrent but not parallel — example: a Python asyncio event loop
running on a single thread. It juggles hundreds of coroutines that interleave
(each yields at await), so many requests make progress "at once", but only
one coroutine ever executes at any given instant. There is no simultaneous
execution — it is concurrent without being parallel.