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
Post a Comment