Chapter 13. Explicit Locks
Before Java 5.0, the only mechanisms for coordinating access to shared data were
volatile. Java 5.0 adds another option:
ReentrantLock. Contrary to what some have written,
ReentrantLock is not a replacement for intrinsic locking, but rather an alternative with advanced features for when intrinsic locking proves too limited.
13.1. Lock and ReentrantLock
Lock interface, shown in Listing 13.1, defines a number of abstract locking operations. Unlike intrinsic locking,
Lock offers a choice of unconditional, polled, timed, and interruptible lock acquisition, and all lock and unlock operations are explicit.
Lock implementations must provide the same memory-visibility semantics as intrinsic locks, but can ...