What is the difference between concurrency and parallelism?
Why Interviewers Ask This
This tests whether you can apply Operating Systems knowledge to real-world scenarios. Interviewers are looking for clarity of thought and evidence that you've encountered this in production code.
Answer
Often used interchangeably but they mean different things: Concurrency: dealing with multiple tasks that make progress over overlapping time periods — tasks are "in progress" simultaneously even on a single core. The OS interleaves execution. Tasks don't necessarily run at the exact same instant. // Single CPU, two threads: Thread A: ----run----wait--run-- Thread B: --------run----wait----run // They overlap in time but not in exact execution. Concurrency is about structure/design — handling multiple things at once by interleaving. Achieved via multitasking on single core. Requires synchronization for shared data. Parallelism: executing multiple tasks simultaneously — they literally run at the same instant on different hardware (multiple cores or CPUs). True simultaneous execution. // Multi-core, two threads: Core 1: ----run----run----run-- Core 2: ----run----run----run-- // Running at literally the same moment. Parallelism is about execution — doing multiple things at the same time. Requires multiple CPU cores. Data must still be synchronized. Rob Pike (Go creator): "Concurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once." — "Concurrency is about structure, parallelism is about execution." Can have: concurrency without parallelism (single-core multitasking); parallelism without concurrency (dedicated pipelines); both (multi-core with multitasking — most modern systems). I/O-bound vs CPU-bound: I/O-bound work benefits from concurrency (overlap I/O wait with other work); CPU-bound work needs parallelism (more cores = faster) and concurrency won't help on single core.
Pro Tip
This topic has Operating Systems-specific nuances that differ from general programming. Highlighting those nuances in your answer shows expertise rather than generic knowledge.