How Threads Actually Work
How Threads Actually Work
Everything you were told about "just add a thread" — examined at the level where it's true. We build the mental model from the CPU upward: what a thread is in hardware, what a context switch actually costs, and why Go and Rust async exist.
Topics covered:
- Register state and the cost of switching
- The scheduler's fairness problem in one diagram
- Priorities, cgroups, and the myth of the "priority" knob
- Goroutines vs OS threads: the 100× gap explained
Related articles
JIT Compilation: Why Hot Loops Become Machine Code
Tiered compilation, on-stack replacement, and deoptimization — when the runtime outperforms the ahead-of-time compiler.
What Happens When You Allocate an Object
Thread-local allocators, TLABs, bump allocation, and why object allocation is nearly free until the moment it isn't.
How Garbage Collectors Decide What to Free
Mark-sweep, generational hypothesis, and GC pauses — the physics of automatic memory management and why it's never truly free.
More in Runtime & Execution
How Garbage Collection Actually Works
A visual walkthrough of mark-sweep, generational collection, and concurrent GC — the algorithms that keep your memory clean.
WatchWhat Your Code Does Before main()
The loader, the linker, the dynamic linker, and the runtime — everything that happens between pressing run and your first line of code.
WatchDepth, delivered weekly
One technical dispatch a week — articles and episode notes before they go public.
One technical dispatch per week. No noise.