Essential Effects logo

Essential Effects

Subscribe
Archives
November 10, 2020

Essential Effects: Concurrency vs. Parallelism

Greetings fine readers-to-be! I wanted to share a small bit about concurrency vs. parallelism, and also remind folks that there are two upcoming "Essential Effects" training courses this month, for both US and EU timezones:

  • November 18-20, US-timezone
  • November 23-25, EU-timezone

The course is a companion to the book:

Essential Effects teaches how to safely create, compose, and execute effectful Scala programs using the Typelevel cats-effect library, and how to integrate these concepts and techniques into your projects.

If you self-identify as underrepresented or unemployed, we're happy to offer a 50% discount, available when selecting "Tickets". Readers like you can also use discount code "newsletter-nov-2020".

.. Adam


Concurrency vs. Parallelism

Although they are often conflated, concurrent and parallel are disparate concepts:

  • concurrent: Computations are concurrent when their execution lifetimes overlap.
  • parallel: Computations are parallel when their executions occur at the same instant in time.

That is to say, concurrency is about the looking at the structure of the computations and how their lifetimes align, whereas parallelism is more about the operational utilization of resources during the execution.

For example, with two threads you could run two computations in parallel (and concurrently!):

But with one thread you could also run two computations concurrently--if you can "pause" one and switch, using the same thread, to the other, and vice-versa, they would execute concurrently:

Concurrency emphasizes the non-deterministic aspects of computation: we can't tell when anything happens, only that their lifetimes overlap. Whereas parallelism requires determinism: no matter how many resources you have, you must produce the same answer.

Don't miss what's next. Subscribe to Essential Effects:
Powered by Buttondown, the easiest way to start and grow your newsletter.