You’ve probably heard people use the words parallelism and concurrency like they mean the same thing. But actually, they’re different.
Parallelism means doing multiple tasks at the same time.
Concurrency is about quickly switching between tasks to make it look like everything is happening at the same time.
Parallelism is when a system has multiple CPUs or cores, and it uses them to run multiple tasks at the same time. Each task runs truly in parallel, without waiting for the others.
This is common in modern computers. For example, if your CPU has 4 cores, it can run 4 tasks in parallel.
Parallelism is great when tasks are independent, meaning they don’t need to wait on each other or share data.
Concurrency is when a system has one CPU, but it tries to handle multiple tasks by switching between them really fast.
It runs one task for a little bit, then switches to another, then another… It feels like everything is happening at the same time, but really it’s just sharing time between tasks.
This is useful when tasks spend a lot of time waiting, like fetching data from the internet or reading from disk.
Find this post helpful? Subscribe and get notified when I post something new!