The Code Codex
Theme
← Notes / Concurrency

note · video14 Oct 2024 · 1 min

Concurrency is not parallelism

Notes on the video

A talk by Rob Pike, one of the creators of Go, at Heroku’s Waza conference in 2012.

  • “The world is not object oriented, it is parallel”

  • Concurrency is about dealing with lots of things at once.

  • Parallelism is about doing lots of things at once.

  • One is about structure, the other is about execution.

Concurrency: 1 core, interleaved tasks

Core 1

A

B

A

B

Parallelism: 2 cores, at the same time

Core 1

A

A

A

Core 2

B

B

B

Concurrency: 1 core, interleaved tasks

Core 1

A

B

A

B

Parallelism: 2 cores, at the same time

Core 1

A

A

A

Core 2

B

B

B

  • Concurrency provides a way to structure the solution to a problem, which may or may not run in parallel.
    • E.g. an operating system manages mouse, keyboard, monitor and speakers at the same time. With one or many cores, the programming model is concurrent, and may or may not be parallel.
  • Concurrency is a way to structure a program, breaking it into pieces that can run independently.
  • A program well structured for concurrency can get parallelism for free when more cores are available; the reverse is not true.

In Go, this shows up in goroutines and channels (Go guide); in Java, in virtual threads.