الشرح أدناه بالإنكليزية، والترجمة العربية لاحقاً.
Concurrency in Motion · Lesson 2
Concurrency vs. Parallelism
Free lessonWhy do developers mix these two up constantly? Because both make a program "do more at once" — but in completely different ways. Getting the distinction clear is the single most useful thing you can do before writing concurrent code.
Concurrency
The ability to deal with many tasks by rapidly switching between them. It's about the structure of your program — it works even on a single core.
Parallelism
The literal execution of many tasks at the very same instant, using hardware that supports it. It's about the physical capability of the processor.
Single-core: the illusion
A single-core CPU fools you. It switches between threads so fast — context switching — that things feel simultaneous, when really they're taking turns sharing one worker. That's concurrency.
Multi-core: the real thing
With multiple physical cores, the system truly splits work across separate cores that run in the very same second. That's parallelism — no illusion, just more hands.
See it step by step
This is the heart of the lesson. Press Play to watch, or use Step to walk through one tick at a time. Both modes do the same work: four ticks of Task A and four of Task B and see exactly how each model uses its core(s). Toggle between the two modes and compare:
Press Play or Step to begin.
The decisive comparison
| Aspect | Concurrency | Parallelism |
|---|---|---|
| Performance | Better responsiveness | Better raw throughput |
| Hardware | Works on 1 core | Needs multiple cores |
| Complexity | Coordination & shared state | Splitting & merging work |
| Typical bug | Race conditions, deadlocks | Load imbalance, false sharing |
The chef analogy
Your web browser does both: it fetches data from a server while still reacting to your clicks (concurrency), and renders heavy graphics on the GPU at the same time (parallelism).