Visual Learn - Master CS concepts
Visualizing Computer Science Concepts
CS Fundamentals
Concurrency vs Parallelism vs Multithreading
They sound similar, but they happen at different levels of the system.
Animations
1Concurrency
terminal.exe
Live
[ EXEC ] [ WAIT ]
| |
v |
[ ๐จ ] [ ]
(Task 1) (Task 2)
CPU: [โ ] 10%
The Illusion of Simultaneousness. Concurrency is about dealing with lots of things at once. It's a structure where a single worker switches between tasks quickly.
2Parallelism
terminal.exe
Live
[ EXEC ] [ EXEC ]
| |
v v
[ ๐จ ] [ ๐ฉ ]
(CPU 1) (CPU 2)
SYSTEM: [โโโโโโโโ] 100%
Truly Simultaneous. Parallelism is about doing lots of things at once. It requires multiple physical workers (CPU cores) running tasks at the exact same moment.
3Multithreading
terminal.exe
Live
PROCESS [================]
|
|--> ๐งต T1 [ ACTIVE ]
|--> ๐งต T2 [ .. ]
|--> ๐งต T3 [ .. ]
Implementation Detail. A technique where a process is split into threads that share resources but execute independently. Can be used for both concurrency or parallelism.
The Golden Rule
"Concurrency is about structure, Parallelism is about execution."