Concurrency vs Parallelism
🆚 Comparison
Definition
Managing multiple tasks at the same time.
Executing multiple tasks at the same time.
Focus
Structure of the program, dealing with multiple tasks.
Execution of tasks simultaneously on multiple cores.
Task Handling
Tasks start, run, and complete in overlapping time periods.
Tasks run at exactly the same time.
Context Switching
Frequent context switching between tasks.
Little to no context switching needed.
Resource Utilization
Better resource utilization via multitasking.
High CPU utilization by running tasks on multiple cores.
Example
Handling multiple I/O-bound tasks.
Performing multiple CPU-bound tasks.
Programming Model
Often achieved with threads, coroutines, and asynchronous programming.
Often achieved with parallel loops, GPU processing, and multi-core processing.
Goal
Improve throughput and responsiveness.
Improve computation speed and reduce execution time.
Typical Use Cases
Web servers handling multiple requests, GUI applications.
Scientific computations, video rendering, real-time simulations.
Performance Gain
Gains depend on effective management of tasks.
Gains depend on the number of available processing units.
🅰️ Concurrency
🅱️ Parallelism
Last updated