Skip to content

Simulations and runnable labs

Each page has two halves. First a simulation in the browser: cause the failure, watch what an engineer would watch, fix it. Then the same failure as a small Java 21 program you can run in Docker with CPU and memory limits, next to the output a real JVM printed.

0 / 8 completed

  1. Simulation 1Thread pool exhaustion: four threads, five times the loadA pool of 4 threads with a queue of 8 gets requests five times faster than it can finish them. Watch the queue fill, compare the rejection policies, and see why an unbounded queue hides the problem.Intermediate20 min· simulation + Docker lab
  2. Simulation 2Lost updates: counter++ is three stepsStep two threads through read, add, write on one shared counter and lose updates on purpose. Then see why volatile does not help and why a lock or a compare-and-set does.Foundation15 min· simulation + Docker lab
  3. Simulation 3Deadlock: two transfers, two locks, opposite orderStep two money transfers into a deadlock, read the wait-for graph and the thread dump that names it, then fix it with one global lock order or a tryLock timeout.Intermediate20 min· simulation + Docker lab
  4. Simulation 4GC pressure: when the live set fills the heapRun a generational heap at 200 MB/s. Raise the live set until G1 falls back to full collections, then see what ZGC does with the same heap.Intermediate25 min· simulation + Docker lab
  5. Simulation 5Heap leak: the cache that never hitsSend requests at a cache whose key has no equals() and hashCode(). Watch the heap floor rise to OutOfMemoryError, then find the cause with two histograms and a heap dump.Intermediate25 min· simulation + Docker lab
  6. Simulation 6Lock contention: eight threads, the throughput of oneEight threads share one synchronized map on two CPUs. Throughput stays at the level of one thread and seven threads sit BLOCKED. Find it in a thread dump and in JFR, then remove the shared lock.Intermediate20 min· simulation + Docker lab
  7. Simulation 7Virtual threads: where they help and where they cannot2,000 requests each wait 100 ms on a remote call. Virtual threads cut 1,027 ms to 127 ms, change nothing when 20 downstream connections are the limit, and get slower when pinned.Intermediate20 min· simulation + Docker lab
  8. Simulation 8CompletableFuture starvation: a pool waiting for itselfFour order tasks on a pool of two each call join() on a price task queued on the same pool. Nothing ever finishes. Step through it, read the thread dump, then fix it with thenCompose.Intermediate15 min· simulation + Docker lab