Now, Most people I talk to confuse concurrency with parallelism or vice – versa. The majority of the people do explain Concurrency with parallelism and then rephrase the same definition to explain Parallelism. This is not the case. These two terms are vastly different. Although they are used in relation when talked about Multithreaded Program execution.
Understanding Concurrency & Parallelism
Let’s understand concurrency first and through it, we will understand Parallelism by pointing out the differences between the two.
When more than one task is running in overlapping time Periods. We can say that this is the concurrent execution of that task. This concurrent execution does not mean that those tasks were being processed/executed at the same time. It could be that there was a switching of tasks under processing.
So Concurrency can be explained as the management of the execution of multiple tasks in the same time period. Concurrency can be achieved in a single Core CPU. Concurrency makes use of Context Switching. Which is the process of storing the state of a process or thread, so that it can be restored and resume execution at a later point.
Unlike concurrency which is more of a management of the execution of multiple tasks. Parallelism actually means when tasks run at the same time. So unlike Concurrency Parallelism requires more than one CPU core. Parallelism greatly increases the computational speed of the system.
Parallelism may break a task into sub task and execute them at the same time. As explained above, Concurrency manages a lot of tasks at the same time. While Parallelism executes a lot of tasks at the same time.
Concurrency means when more than one tasks execute at overlapping time Periods. Without ever executing at the same time Instant.
Parallelism means when more than one task execute at the same time.