On Tue, 21 Jul 2026 17:53:10 GMT, Per Minborg <[email protected]> wrote:
>> Right, `acquireMutex` returns `null` when the `mutexes` array is `null`, but >> it is written and read using plain writes/reads. I think if we want a >> guarantee that setting the `mutexes` to `null` is ordered after the set of >> the value, it should use a `putReferenceRelease`, and likewise, reading it >> in `acquireMutex` should use `getReferenceAcquire`. > > The `mutexes` field is accessed using `volatile` semantics, as that field is > declared as `volatile`. I think this gives us the visibility/ordering we are > looking for. I.e., if the value is set and then `mutexes` is set to `null` > then, if we see `mutexes == null` (using `volatile` semantics), we are > guaranteed to see the value. As I said "not obvious". :) So we have: set(array, index, mutex, newValue); // putReferenceRelease of newValue putReferenceVolatile(mutexes, offset, TOMB_STONE); mutexes = null; // volatile write Thanks for clarifying. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/31979#discussion_r3627053408
