Skip to content
Back to the catalog
Project thread-poolConcurrencyAdvancedComing soon

Build your own thread pool

Build a thread pool from scratch. Coordinate queues, mutexes and condition variables to distribute work safely and measure concurrent performance.

Build it in your language

The tester treats your program as a black box: any language works. These are just the most convenient ones for this project.

Guide language

The stage guides read in this language. Only languages this project is fully translated into show up here; the interface language does not change.

What this project is about

Project in preparation: we are completing and verifying the implementation path and its tests. The capabilities below describe the project goal; starting the project is not enabled yet.

You learn concurrency badly by reading: you have to watch it fail. This challenge is built so you watch it fail in a controlled setting and learn to fix it with the right tools.

You'll build a reusable thread pool, from the naive one-mutex version to one with work stealing, orderly shutdown and error propagation. And you'll measure every version, because in concurrency intuition lies.

Roadmap

8 stages across 4 phases. Every stage comes with its guide and its tests: you move on when they pass.

  1. Phase 12 stages

    Work in parallel

    Spawn threads, hand out tasks through a queue, and watch the first race appear.

  2. Phase 23 stages

    Synchronising properly

    Mutexes, condition variables, and workers that wait without burning CPU.

  3. Phase 32 stages

    A usable pool

    Tasks with results, propagated errors, and orderly shutdown.

  4. Phase 41 stage

    Performance

    Local queues, work stealing, and measuring contention.

Before you start

A ready-to-use thread pool library: a task queue guarded by a mutex and a condition variable, a configurable number of workers, task submission with results, orderly shutdown that loses no work, panic or error propagation, and a variant with local queues and work stealing.