HotSpot mark word layout and lock states (unlocked, lightweight, heavyweight, GC mark)

Concurrent Hash Table Designs: Synchronized, Sharding, ConcurrentHashMap, and NonBlockingHashMap

The next milestone is to build a fully thread-safe hash map. Up to this point, the focus has been entirely on single-threaded performance: minimizing memory overhead, improving cache locality, and squeezing out every last bit of throughput from the underlying data layout. However, real-world applications rarely stay single-threaded. To be practically useful, a hash map must behave correctly—and efficiently—under concurrent access. Before jumping straight into implementation, it’s worth stepping back and studying how existing thread-safe hash map implementations approach this problem. Different designs make different trade-offs between simplicity, scalability, memory usage, and read/write performance. By examining these approaches side by side, we can better understand which ideas scale cleanly—and where the pitfalls are—when multiple threads hit the same structure at once. ...

December 27, 2025 · 50 min · Donghyung Ko

Kotlin Coroutine Internals: Suspension, Continuation, CPS

This post explains how coroutines work, referencing the design proposal Kotlin Proposals - Coroutines. Coroutine The proposal describes a coroutine in one sentence as an instance of suspendable computation. The essential trait of a coroutine is its ability to suspend. So what exactly does “suspendable” mean? Suspension According to the proposal, suspendable means a coroutine can pause execution on the current thread, yield the thread so another coroutine can run, and later resume—possibly on a different thread. ...

July 7, 2023 · 8 min · Donghyung Ko