Please explain me more the contract. I can't figure out if two locks contained in ReentrantReadWriteLock
somehow related? Or these are just a bundle of two normal locks?
If threads are waiting Read Lock it is shared but when thread wants to acquire write lock only that thread is allowed the access same as mutual exclusion.
So either one of operation is allowed .if lock is held by readers and thread request write lock no more readers are allowed to acquire read lock until thread which has acquired write lock release it
.