Skip to content

Instantly share code, notes, and snippets.

@yoshuawuyts
Last active May 5, 2023 18:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoshuawuyts/4bf8eefb5c22a66216b1a880e5271a9e to your computer and use it in GitHub Desktop.
Save yoshuawuyts/4bf8eefb5c22a66216b1a880e5271a9e to your computer and use it in GitHub Desktop.

Concurrency vs Parallelism, in table form

Concurrency is a system-structuring mechanism, parallelism is a resource. (ref)

There's an important distinction between "parallelism" as a resource, and "parallel execution". The two are often confused, but they are in fact distinct. The key separator is "concurrency":

no parallelism has parallelism
no concurrency sequential execution sequential execution †
has concurrency concurrent execution ‡ parallel execution

† I feel like this one trips people up the most. A classic example of this is two separate threads only making progress while they have access to an exclusive resource. They will take turns in making progress, leading to sequential execution. Just having multiple threads or cores available is not enough; you actually need to correctly schedule on them to achieve parallel execution.

‡ An example of this is: sleep for ten seconds + compute numbers of PI. You're doing two things at the same time, but one task is off-cpu and only one is on-cpu. This is concurrent execution, despite the absense of parallelism as a resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment