public void m() { lock.lock(); // block until condition holds try { // ... method body } finally { lock.unlock() } } }}
In addition to implementing the {@link Lock} interface, thisclass defines a number of {@code public} and {@code protected}methods for inspecting the state of the lock. Some of these methods are only useful for instrumentation and monitoring.
Serialization of this class behaves in the same way as built-in locks: a deserialized lock is in the unlocked state, regardless of its state when serialized.
This lock supports a maximum of 2147483647 recursive locks by the same thread. Attempts to exceed this limit result in {@link Error} throws from locking methods.
@since 1.5
@author Doug Lea