[concurrency-interest] ReentrantReadWriteLock sample usage - redundant volatile

Doug Lea dl at cs.oswego.edu
Tue Dec 13 16:08:15 EST 2016

On 12/12/2016 03:55 PM, Roman Leventov wrote:
> It seems that in "CachedData" sample usage in ReentrantReadWriteLock
> class-level Javadoc comment volatile on cacheValid field is redundant,
> because cacheValid is only accessed when readLock or writeLock is held,
> that should guarantee total memory safety.

Thanks; changed. Omitting "volatile" here might reduce confusion.
My vague recollection is that the example was abstracted from
an actual usage, where there may have been some reason to rely on
volatile in other parts of the code.


More information about the Concurrency-interest mailing list