OPERATING SYSTEMS & GOLANG

Concurrency Vs. Parallelism: Differences

Nishee Jaiswal
3 min readJun 28, 2021
Concurrency vs. Parallelism

The difference between concurrency and parallelism is frequently asked in the interviews. Both are often misconceived as similar terms but are distinct.

Let’s understand concurrency first.

Concurrency is the act of managing and running multiple computations at the same time. It means that multiple computations are handled at the same time but not simultaneously. In reality, maybe one computation is running at a time and the control is switched from one to another computation.

No talking while eating, please!

For example, we cannot speak properly while eating something. But after swallowing the bite we can speak. And then again we take a bite and after swallowing it we can again talk. At a time we are speaking or talking, that is what multitasking is and there exhibits concurrency. In the given example we are switching between eating or talking.

Talk and then eat.

Now let’s understand parallelism.

Parallelism is the act of running multiple computations simultaneously. It means more than one computation running at the same time.

For example, a person could dance and sing at the same time, that is parallelism. There is no switching over the task.

Let’s sing and dance!

Let’s take another example for concurrency, it will give you more visuals about the topic. Let us consider there are two persons standing.

The first person and second person are standing.

The first person started walking and then got tired and stopped.

The first person got tired and stopped.

Then the second person started walking and reached the destination.

The second person started walking and reached the destination.

Then again the first person started walking from where it stopped and reached the destination.

The first person now again started walking and reached the destination.

These persons are not walking at the same time, they are walking one after another.

In a real-life implementation, these persons could be processes executing concurrently. These processes could have overlapping times but never execute at the same time. Similarly, CPU control is switched from one process to another. This mechanism is also known as context-switching.

Let’s take a similar example for parallelism. Now we have two persons walking simultaneously at the same time and reached the destination without taking any rest.

Both the persons started walking at the same time.
Both the persons reached the destination without taking any rest.

In a multiprocessor system, a task is sub-divided into multiple sub-tasks and then each subtask is executed in different processing units. In that case, the subtasks are running in parallel and that is parallelism.

Now, we will distinguish concurrency and parallelism with the help of the following table.

Always keep in mind that parallel processes should be concurrent if they are operated at the same instant but concurrent processes could never be parallel because they are not processed simultaneously. Hence, it is said that concurrency enables parallelism.

--

--