Skip to content

Blog

Production error deep-dives — root cause, reproduction, and the fix that holds.

Semaphore in Java: Permits, Leaks and Virtual Threads

A Java Semaphore is a counter with a wait queue, not a lock. Why release() can mint permits, how leaks starve a pool, and how to cap virtual threads safely.

Race Conditions in Java: Check-Then-Act Without a Data Race

A race condition in Java can survive a ConcurrentHashMap and synchronized on every call. Check-then-act, critical sections, and how to prove the bug is there.

Custom Exception in Java: Write Ones That Explain Themselves

A custom exception in Java should tell you which value, which layer and why. How to write messages, chain causes and rethrow without losing the trace.

How to Use ScheduledExecutorService for Periodic Tasks in Java

In financial systems built on Apache Kafka and Flink, background scheduling is everywhere: checking consumer lag every 30 seconds, expiring distributed locks after a payment SLA window, scheduledExecutorService is production-grade answer to all of this.

How to Use PriorityQueue and TreeMap in Java (Java 21)

Build a support-ticket desk in Java 21: a PriorityQueue that hands out the next ticket, a TreeMap that answers SLA deadline questions, and seven forced traps.

Thread Join in Java: What join() Locks and Never Tells You

Thread join in Java waits on the Thread's own monitor, can't tell a timeout from success, and ignores failure. What join() promises, and what it hides.

GC Roots in Java: How the JVM Decides What Is Garbage

GC roots decide what the JVM keeps alive. Thread stacks, statics, JNI handles and references, measured on JDK 21, plus the JIT surprise that frees a live local.

Thread Starvation in Java: Pools, Carriers and Priorities

Thread starvation in Java rarely comes from unfair locks. Pool starvation, head-of-line blocking and CPU-bound virtual threads cause it, and I ran each one.

How to Implement the Command Pattern in Java (Java 21)

Implement the command pattern in Java 21 on a to-do list with undo, redo and macro commands, backed by 18 checks and the traps that quietly break undo.

ReentrantLock in Java: tryLock, Fairness and Interrupts

A fair ReentrantLock still lets tryLock() cut the line, and a forgotten unlock() outlives its thread. ReentrantLock explained with a lab, dumps and numbers.