Last Updated: June 6, 2026
The synchronized keyword is Java's original tool for protecting shared data. It works, but it's rigid: no "wait at most one second", no interruption while waiting, and no way to wake one waiter while keeping another asleep. The java.util.concurrent.locks package, added in Java 5, provides a more flexible alternative. This lesson covers the Lock interface, the try { lock(); } finally { unlock(); } pattern that keeps locking safe, the three things explicit locks can do that synchronized cannot, and the Condition interface that lets a single lock host multiple independent wait queues. The chapter ends by rebuilding a bounded order queue using a Lock and two Condition objects.