Concurrency and Multithreading
Core idea: Concurrency means multiple threads make progress over the same time window — often interleaving on the same CPU. The instant they share data, the order of their individual steps is no longer guaranteed, and "obviously correct" code can produce impossible results. The whole discipline is coordinating access to shared state so every interleaving is still correct.
Concurrent ≠ parallel
- Concurrent — multiple tasks in progress over the same period; they may interleave on one core (the scheduler switches between them).
- Parallel — tasks literally running at the same instant on different cores.
You write concurrency code (locks, conditions) to be correct under either. The hard part isn't speed — it's that the scheduler can pause a thread between any two statements.
Sign in to continue reading
The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.
Sign in to read the full lesson