📖 Book · multithreading · high

🔀 A thread pool, from scratch

Task queue + condition_variable + std::future, with deadlock-free graceful shutdown.

Build a working thread pool / executor: a thread-safe task queue, condition_variable signalling, submit() returning std::future, and the subtle shutdown protocol that drains tasks and joins workers without lost-wakeup deadlock. Real concurrency, runnable.

5 chapters▶ runnable code✦ in-depth animation

What this book covers

  1. 01Why pool threads at all?
  2. 02The four moving pieces
  3. 03The whole pool — submit, run, return a future
  4. 04Graceful shutdown without deadlock
  5. 05Gotchas & where to take it next

Read it in full — runnable C++ + step-through animations

Every chapter of A thread pool, from scratch ships complete, editable code you compile and run in the browser, plus the same in-depth animations as the lessons.