https://kotlinlang.org logo
#random
Title
# random
a

Albert

09/24/2018, 9:28 AM
Out of curiosity, why is
read
extension method added on
ReentrantReadWriteLock
and not the interface
ReadWriteLock
?
1
h

hudsonb

09/24/2018, 1:38 PM
I'd guess it is because what exactly needs to be performed may vary between implementation of that interface. For example for
ReentrantReadWriteLock.write
attempts to "upgrade" from a read lock to a write lock if neccessary by releasing all read locks, obtaining a write lock, performing the task, then acquiring the read locks again.
👍 1
2 Views