Multithreading
Concurrency, parallelism, and thread-safe programming, as they actually get asked in senior interviews.
Everything here answers one question wearing different costumes: who is allowed to proceed, and who tells them? Start with the 101 to get the vocabulary, learn the framework to get a repeatable method, then work the ten pattern families. The problems under each pattern are there to be solved, not read.
Start here
- Multithreading 101: everything you must know. The concepts, the JMM, the primitives, the failure catalog. One page, no problems, all vocabulary.
- What do you actually do in a Multithreading interview?. Classify → invariant → pattern → template → verify, in 45 minutes.
Patterns
Ten families cover every concurrency question I’ve seen asked. Each playbook has the mechanics, the derivation recipe, and the failure modes; each problem below it is a worked application.
Families 1 to 7 are the coordination core, learn these first and in order. Families 8 to 10 are the senior material: what correctness costs at scale, whether you can find someone else’s bug, and whether your instincts survive the process boundary.
The coordination core
- Ordering & Turn-Taking. The baton: who acts next, who hands it over
- Guarded State & Mutual Exclusion. One invariant, one lock, and the check-then-act disease
- Bounded Resource & Producer-Consumer. Two parties waiting on opposite predicates
- Group Formation & Barriers. Admission and boundary, kept separate
- Asymmetric Access & Readers-Writers. The lightswitch, and choosing who starves
- Task Lifecycle, Async & Parallelism. Where is the work, and who is counting it
- Time-Based State. State as a function of the clock
The senior material
- Concurrent Data Structures. Guarded state with a throughput requirement: does the invariant decompose?
- Debugging & Code Review. Run the method backwards: symptom → cause → proof
- Distributed Concurrency & Idempotency. The same problems with no shared memory and partial failure
How to use this
Read the problem statement, close the page, and try it for 15–20 minutes in a blank editor. Only then read the strategy. The strategy pages deliberately contain no full solutions. They give you the invariant, the mental model, and the failure modes, so you reconstruct the code from understanding rather than recall. If you can’t rederive it a week later, you memorized it.
Two families break that loop on purpose. In Debugging & Code Review there is nothing to code first: the diagnosis is the deliverable, so work aloud from symptom to hypothesis to reproduction to fix before opening the strategy. In Distributed Concurrency these are spoken design answers: always give the single-JVM answer first, in code-level detail, and name its linearization point before you name any datastore. That ordering is itself part of what gets graded.