We just released our Beginner Hardware Design roadmap. We're leaning into HWE interview preparation. The price will rise as the content expands.

Logo

Implement std::jthread

What this preview is

Implement std::jthread is a hard quant coding problem on concurrency in Cpp.

Difficulty
Hard
Topic
Concurrency
Discipline
Quant development
Language
Cpp

Implementing std::jthread with stop-token support in C++

This is a hard coding problem that tests your ability to design and implement a modern C++ synchronization primitive from first principles. It combines thread lifecycle management, callable-type introspection, and lock-free state coordination—all of which appear in systems code at trading firms and infrastructure teams.

The problem requires you to build a joinable thread wrapper that automatically joins (and can cancel) on scope exit, avoiding the silent termination that can occur with raw std::thread. Key challenges include detecting whether a callable accepts a stop token at compile time, managing the transition from active to canceled state without locks, and ensuring thread safety across destruction, detachment, and external cancellation requests.

  • SFINAE or std::invoke_result for callable type checking
  • Atomic flags and memory ordering for lock-free synchronization
  • Thread lifecycle: construction, detach, join, and scope-based cleanup
  • Implicit conversions and move semantics restrictions

Unlock full access to getcracked

Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.