Query regarding read-write locks
I am delving on the java concurrent APIs and trying to understand the
usefulness of read-write locks. The javadoc says that a readwrite block
maintains a pair of locks, one for read and the other for write
operations. While the write lock is exclusive access by a thread, multiple
threads can acquire the read lock. So if in the read section all we are
doing is read operations and we are anyways providing multiple threads
access, what is the need to have the readlock in the first place ? Is
there a scenario when the readwrite lock is actually useful?
No comments:
Post a Comment