August 2018
Intermediate to advanced
524 pages
14h 45m
English
This class is an implementation of ReadWriteLock. ReadWriteLock is a lock that can be used for parallel read access and exclusive write access. It means that several threads can read the resource protected by the lock, but when a thread writes the resource, no other thread can get access to it, not even read it during that period. A ReadWriteLock is simply two Lock objects returned by the readLock() and writeLock() methods. To get read access on ReadWriteLock, the code has to invoke myLock.readLock().lock(), and get access to the write lock, myLock.writeLock().lock(). Acquiring one of the locks and releasing it in the implementation is coupled with the other lock. To acquire a write lock, no thread should have an active ...