On Fri, 6 Sep 2024 14:06:08 GMT, Viktor Klang <vkl...@openjdk.org> wrote:

>> My understanding is that `volatile` is used when accessing the contents of 
>> the object, which we are not doing with this locking object, so IMO there is 
>> no reason for the keyword to be added.
>> 
>> I'll apply your other suggestion about explicit comments.
>
> If the lock is used for double-checked locking the member which is lazily 
> initialized needs `volatile` if the instance is not completely immutable.

I added the above comments, as suggested, in 
https://github.com/openjdk/jdk/pull/20301/commits/5573558cc0c78a2acc9713d27eab8a082ce5ff78.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20301#discussion_r1747569424

Reply via email to