DEV Community

Cover image for Concurrency is not the parallelism

Concurrency is not the parallelism

Omkar Ajnadkar on November 24, 2018

This post is inspired by two things: How to make Python code concurrent with 3 lines rhymes ใƒป Nov 23...
Collapse
 
drbearhands profile image
DrBearhands

So I'm going to be rather negative here, because I think I should be.

The first line on wikipedia:

In computer science, concurrency refers to the ability of different parts or units of a program, algorithm, or problem to be executed out-of-order or in partial order, without affecting the final outcome.

vs. your post:

Concurrency: Fooling you and running processes alternatively

There is quite a difference.

And parallelism does not require multiple cores. That's just one way of doing things.

Although we have all made mistakes and said something inaccurate at some point in time, for posts, which take time to make anyway, you should really make a minimal effort to check your assumptions. Otherwise, you spread misinformation and confusion among your readers, essentially making them slightly worse devs after reading this.


  • Concurrent: not (completely) ordered; at least some parts can run simultaneously.

  • Parallel: parts do run simultaneously.

  • Interleaved: 'mixed' but not run at the same time (situation 2 from the post).

So concurrent code can be executed in parallel, interleaved or entirely sequentially.

In software development you don't generally have full control over how your program will run exactly; you can give hints but your OS will make decisions based on e.g. the current load.
That means that generally we talk about concurrent software and parallel hardware, but that is not part of the distinction.

There is quite a variety in how things can be parallel (multi-cores, hardware threads, GPU, VLIW, FPGA...), you can even sort-of run sequential code in parallel (pipelines), which we do all the damn time.

Collapse
 
blackbird profile image
Omkar Ajnadkar

Hey,
Thanks for your suggestions. Although I am no expert in this topic, what I am trying to explain here is the difference between parallelism and concurrency. This is for those who think that parallelism is equivalent to concurrency, which is not and that's what I am trying to explain here.
In the line,

Concurrency: Fooling you and running processes alternatively

I am just trying to explain that concurrency does not mean processor is running more than one process simultaneously but user is thinking that more than one process is running.

Collapse
 
drbearhands profile image
DrBearhands • Edited

I'm sorry, but your intention is irrelevant in this. Whatever it is you intended to do, what you have achieved is misinforming people.

You should edit your post to correct this for future readers (or delete it if you do not feel up to editing it).

Collapse
 
tchupp profile image
Theo Chupp

This has a similar title to one of my favorite talks, by Rob Pike.
blog.golang.org/concurrency-is-not...

Collapse
 
bgadrian profile image
Adrian B.G.

I was sure that is a Go post, it is a common phrase in Gos community.

Collapse
 
trueneu profile image
Pavel Gurkov

Please don't misinform other people.

Collapse
 
smailg profile image
SmailG

I guess if you talk about this threads should also be spoken about, as well as multiple cores dealing with the same process eg. games