On Thu, 30 Jul 2026 03:07:51 GMT, David Holmes <[email protected]> wrote:

>> Per Minborg has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   Fix comment
>
> src/java.base/share/classes/java/util/LazyCollections.java line 625:
> 
>> 623:             UNSAFE.putReferenceVolatile(mutexes, offset, TOMB_STONE);
>> 624:             // This access mode provides both acquire and release 
>> ordering which is
>> 625:             // needed here.
> 
> Can you elaborate on this. AFAICS you need strong ordering between the 
> setting of a TOMB_STONE and the null'ing of `mutexes`, but as both of those 
> are volatile writes you implicitly have that. The counter decrement needs to 
> be atomic for correctness of the null'ing logic, but the implicit 
> acquire/release of that atomic op seem irrelevant to anything except the 
> atomic op itself.

You are right that the code works as it is. But one of my objectives with this 
PR is to intentionally make that ordering explicit through the counter rather 
than relying on incidental volatile operations elsewhere.  

Imagine someone else (like myself in six months) not seeing this intricate 
dependency and breaking the code via some good-intentioned "optimization".

I’ll expand the comment to explain the cross-thread publication requirement.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32070#discussion_r3688569406

Reply via email to