Concurrency Defined: Multiple Tasks in Progress
You'll learn the formal definition of concurrency and how it differs from simultaneous execution.
The Core Idea
Concurrency means dealing with multiple tasks that can make progress without necessarily executing at the exact same instant. Think of it as juggling: you're only throwing or catching one ball at a time, but you're managing multiple balls "in the air" by rapidly switching between them. The balls don't fly simultaneously through your hands, yet all are progressing toward completion.
In computing, concurrency is about structuring your program so multiple tasks can be in progress at overlapping time periods. These tasks might:
- Execute in turns on a single processor core (interleaved execution)
- Actually run simultaneously on multiple cores (parallelism, a subset of concurrency)
- Wait for external events (like network responses) while others proceed
Why This Matters
Concurrency doesn't guarantee parallelism (true simultaneous execution). A single-core machine can still run concurrent programs by rapidly context-switching between tasks. The operating system or runtime gives each task a time slice, creating the illusion of simultaneity even though only one instruction executes per clock cycle.
Real-World Analogy
Imagine a chef preparing multiple dishes. With one pair of hands, they can't literally chop vegetables and stir a pot at the same moment. But they can start the soup boiling, chop vegetables while it simmers, check the oven, then return to the soup—all dishes make progress concurrently through smart task interleaving.
Key Takeaway: Concurrency is about managing multiple tasks making progress over overlapping time periods—not necessarily executing at the exact same instant—through interleaving or parallel execution.