ReentrantLock
The Lock
interface in Java offers a choice of unconidtional, polled, timed, and interruptible lock acquisition, and all lock and unlock operations are explicit. ReentrantLock
implements Lock
, providing the same mutual exclusion and memory-visibility gurantees as synchronized
. Acquiring a ReentrantLock
has the same memory semantics as entering a synchronized
block, and releasing a ReentrantLock
has the same memory semantics as exiting a synchronized
block.