Skip to content

Instantly share code, notes, and snippets.

@natthasath
Created June 24, 2024 02:55
Show Gist options
  • Save natthasath/75b1f387e447a1f697bcef390a13c833 to your computer and use it in GitHub Desktop.
Save natthasath/75b1f387e447a1f697bcef390a13c833 to your computer and use it in GitHub Desktop.
concurrency-vs-parallelism.md
Feature Concurrency Parallelism
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment