What Is the Difference Between Concurrency and Parallelism?

Concurrency is about dealing with a lot of things at once, parallelism is about doing a lot of things at once

Kelvin Muchiri
Explain it to grandma
3 min readApr 15, 2023

--

Photo by Usman Yousaf on Unsplash

A little bit of history

Computers have evolved fast from the time they were introduced. The first computers had single-core processors, meaning they could only process one operation at a time. An operation had to wait for another operation for that operation to start.

Single-core processors were designed for the sequential execution of programs, where the first task is followed by the second, the second by the third and so forth.

For example, if you wanted to fry an egg, you’d start by placing the pan on the fire, putting some olive oil on the pan, cracking the egg onto the pan, letting the egg cook and then serving the egg. You cannot execute these steps in any order.

The advent of multi-core processors introduced computers that could handle multiple processes at the same time. With multiple processors, multiple operations can run at the same time.

Programs in which the tasks do not need to be executed in any order could take advantage of multi-core processors to process the tasks simultaneously and hence execute faster.

For example, frying an egg and boiling meat can be executed in any order and they can occur simultaneously. The result of one does not affect the completion of the other.

Nonetheless, you’ve probably heard that single-core processors can also handle multiple operations at the same time.

That is partially true, and that’s where the debate between concurrency and parallelism comes into play.

Concurrency vs parallelism

This great analogy from Grokking Concurrency by Kirill Bobrov paints a perfect picture.

Imagine you are chopping salad while occasionally checking the meat in the oven. You must stop chopping, check the oven, and then resume and repeat the process until everything is done. We have one processing resource here (you). This is concurrency.

Now imagine you are in the kitchen with a friend. Your work is to chop the salad while your friend’s work is to check the oven. We have divided the work by adding another processing resource (your friend). This is parallelism.

Concurrency is about dealing with a lot of things at once. Parallelism is about doing a lot of things at once
— Rob Pike

  • Concurrency is about multiple tasks which start, run, and complete in overlapping periods, in no specific order. Parallelism is about multiple tasks or subtasks of the same task that run simultaneously.
  • Concurrency is about structure. It is about the design of the system. It’s a way to structure a solution to a problem that may not necessarily be parallelizable. Parallelism is about the actual execution.
  • Concurrency can be done using a single processing unit. By using scheduling algorithms that divide the CPU’s time (time slice), processes are interleaved. Parallelism requires hardware with multiple computing resources like multi-processor and multi-core systems for the simultaneous execution of processes.
  • Concurrent programming is usually considered to be more general than parallel programming because it can involve arbitrary and dynamic patterns of communication and interaction, whereas parallel systems generally have a predefined and well-structured communications pattern

Conclusion

There exists a very thin line between the two terminologies. Programmers usually use them interchangeably since many programs have aspects of each.

Now that you know their differences, be keen to use the correct terminology when the context warrants it to avoid confusion.

Thanks for reading this article! Leave a comment below and tell me what you think.

Resources

[1]: Grokking Concurrency by Kirill Bobrov

[2]: Wikipedia. Concurrency https://en.wikipedia.org/wiki/Concurrency_(computer_science)

--

--

Kelvin Muchiri
Explain it to grandma

Computer scientist. I enjoy sharing the graph of thoughts in my head, one node at a time. I write about tech, chaos theory and philosophy