This package defines Lock and associated Condition interfaces as well as concrete implementations (such as ReentrantLock ) that provide an alternative to locking with synchronized blocks and methods and to waiting with the wait( ) , notify( ) , and notifyAll( ) methods of Object . Although Lock and Condition are somewhat more complex to use than the built-in locking, waiting, and notification mechanisms of Object , they are also more flexible. Lock , for example, does not require that locks be block-structured and enables algorithms such as "hand-over-hand locking" for traversing linked data structures. A thread waiting to acquire a Lock can time out or be interrupted , which is not possible with synchronized locking. Also, more than one Condition can be associated with a given Lock , which is simply not possible with Object -based locking and waiting. The ReadWriteLock interface and its ReentrantReadWriteLock implementation allow multiple concurrent readers but only a single writer thread to hold the lock. Interfacespublic interface Condition ; public interface Lock ; public interface ReadWriteLock ; Classespublic abstract class AbstractQueuedSynchronizer implements Serializable; public class AbstractQueuedSynchronizer.ConditionObject implements Condition, Serializable; public class LockSupport ; public class ReentrantLock implements Lock, Serializable; public class ReentrantReadWriteLock implements ReadWriteLock, Serializable; public static class ReentrantReadWriteLock.ReadLock implements Lock, Serializable; public static class ReentrantReadWriteLock.WriteLock implements Lock, Serializable; |