Intro
Hello, just small notes to myself on the definitions of Parallel vs Concurrent programming. Hope it helps differentiate the meanings into distinct mental boxes for you 🤙
Parallelism
This is where a program executes multiple tasks at once, literally, through different threads. And so, as a result, the tasks execute at the same time.
Parallelism usually requires some sort of hardware support. For example, when running a program in parallel, there would usually be two or more cores helping tasks to run at the same time with no dependency on each other. If there was a dependency in one task on the other, then it would be more difficult to assume Parallelism as you'd have to wait for one task to finish it's par to start the other.
Concurrency
Concurrency in it's literal definition means the same thing as parallelism, looking at the oxford definition:
the fact of two or more events or circumstances happening or existing at the same time
It feels like there's two definitions of this term among many developers, and the other term is more specific in that it executes task differently than Parallelism does. According to a post on Stack Overflow (the ocean of knowledge that helps us keep our jobs everyday 😄):
Concurrency is when the execution of multiple tasks is interleaved, instead of each task being executed sequentially one after another. - link to post here
So, instead of doing everything at the same time, tasks are executed interchangeably; when one task is halted and waiting for something, the thread can go somewhere else and tackle a different task. In terms of hardware support, a thread executing instructions would typically only execute one instruction at a time, but can interchange between instructions so fast that it looks like it's doing it at the same time.
A note to remember is that parallelism is a term that lives inside the broader concept of concurrency, because they both share the definition of simultaneous executions. The more specific definition of concurrency, however, does not equate to parallelism because of what we just mentioned.
Please feel free to correct me on the definitions if you see something incorrect, would be much appreciated! 🙌
Top comments (0)