Concurrency vs Parallelism
-
Concurrency is when multiple tasks can run in overlapping periods. It’s an illusion of multiple tasks running in parallel because of a very fast switching by the CPU. Two tasks can’t run at the same time in a single-core CPU. Parallelism is when tasks actually run in parallel in multiple CPUs.
-
Concurrency is about managing multiple instruction sequences at the same time, while parallelism is running multiple instruction sequences at the same time.
-
In Python, concurrency is achieved by using
threading
, while parallelism is achieved by usingmultitasking
. -
Concurrency needs only one CPU Core, while parallelism needs more than one.
-
Concurrency is about interruptions, and parallelism is about isolation.
This is a sapling 🌱 in my digital garden 🏡.