Cards/ConcurrencySystem Design · Day 55Sep 26, 2026

The Keyword That Rewrites Our Method

A sequential async method compiled into a state machine that releases its thread at every await and keeps locals on the heap, beside C# rewriting the code and Java rewriting the runtime

await looks like waiting. It does the opposite — it tells the runtime to stop occupying a thread while nothing is happening.

What we write is a simple sequential method: fetch the user, fetch their orders, return a result. What runs is a state machine. The compiler splits the method at every await, moves the local variables onto the heap so they survive the gap, and releases the thread at each suspension point. When the I/O completes, execution resumes at the next state, possibly on a different thread.

The method pauses. The thread doesn't.

One consequence spreads outward. A method that awaits returns a Task, so every caller must await too, all the way up.

C# rewrites the code and Java rewrites the runtime. Same destination, different routes, and no way to meet in the middle.

Two good teams facing the same constraint will often solve it in incompatible ways — and both will be right.

Two good teams facing the same constraint will often solve it in incompatible ways — and both will be right.