Skip to content

thread-safety

7 Posts

Wait and Notify in Java: The Rules That Stop the Hangs

wait() and notify() hang or corrupt data when the guard, the lock or the wakeup is wrong. Lost signals, stolen wakeups and notify vs notifyAll, run on JDK 21.

Java Condition Variables: await/signal vs wait/notify

A Java condition variable gives one lock several wait sets. How await() and signal() work, why one Condition hangs a buffer, and a bounded buffer done right.

How to Use synchronized Blocks and Methods Correctly in Java

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