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.
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.
A fair ReentrantLock still lets tryLock() cut the line, and a forgotten unlock() outlives its thread. ReentrantLock explained with a lab, dumps and numbers.
Found one Java-level deadlock in a thread dump? How to read it, what ThreadMXBean misses (virtual threads, pool starvation), and the fixes that hold.
Learn how to use Java's synchronized keyword correctly — with real payment and banking examples covering race conditions, synchronized methods, blocks, deadlock-free transfers, double-checked locking, and virtual thread pitfalls. Covers Java 8 through 21
Learn how to use Java's CompletableFuture for async programming — with real payment pipeline examples covering supplyAsync, thenCompose, thenCombine, error handling, and custom thread pools. Covers Java 8, 9, and 21.
Why your pool never grows past core size. How ThreadPoolExecutor admits tasks, why the queue fills first, and what each rejection policy does, with lab output.
A virtual thread stack trace looks normal, minus the carrier. Why the thread name is empty, what each frame means, and how StructuredTaskScope rethrows.
Learn how to use Java's ScheduledExecutorService for periodic tasks — with real Kafka and payment pipeline examples covering scheduleAtFixedRate, scheduleWithFixedDelay, exception handling, graceful shutdown, and virtual threads. Covers Java 8 through 21.
A CompletableFuture stack trace points at a pool worker and says nothing about who submitted the task. How to read async Java traces and get that context back.
ConcurrentModificationException usually has nothing to do with threads. Here is exactly what modCount does, why it fires, and the four fixes that actually work.