Skip to content
Back to the catalog
Project thread-poolConcurrencyAdvancedBeta

A thread pool

Queues, mutexes and condvars. Spread work across threads without data races, and measure it properly.

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

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.

    1. 01Workers and tasks
    2. 02The queue race
  2. Phase 23 stages

    Synchronising properly

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

    1. 01Protected queue
    2. 02Condition variable
    3. 03Capacity and backpressure
  3. Phase 32 stages

    A usable pool

    Tasks with results, propagated errors, and orderly shutdown.

    1. 01Results and errors
    2. 02Graceful shutdown
  4. Phase 41 stage

    Performance

    Local queues, work stealing, and measuring contention.

    1. 01Work stealing and metrics

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.