locking - Why do we need a java lock for just reading? -


w.r.t readwritelock, why need lock while trying read something? locking in knowledge used if mutating variable, not reading avoid concurrent threads trying mutate variable. why need lock reading?

the point of readerwriterlock make sure no other thread mutates while read it.

the read portion of lock not exclusive (there can multiple concurrent readers), except regard write portion (readers wait writer , vice-versa).


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -