ReentrantReadWriteLock is a Java class providing the lock for working with multiple threads.
ReentrantReadWriteLock is a Java class providing the lock for working with multiple threads.
This lock assumes that some resource can be unlocked (ready to lock before working with it), locked read only (multiple threads can access but none can modify) or locked read/write (only one thread can access and modify). Locks are claimed by calling methods on the lock object. If locks cannot be granted immediately, these calls suspend the current thread. Write lock can be downgraded to the read lock (but not in reverse).
To be sure the resource will not stay permanently locked because of exception, the lock in normally released inside the finally
construct.