On Mon, 8 May 2023 09:21:54 GMT, Aleksey Shipilev <sh...@openjdk.org> wrote:

>> Yes `done` must be volatile. Surprised this even worked as expected.
>
> Same as we saw with `isAlive` before: `LockSupport.park` implicitly provides 
> a compiler barrier. This `done` should be at least "opaque" to carry the same 
> effect.

Yes, `park()` and `unpark()` having release and acquire semantics is not 
documented 
[here](https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/concurrent/locks/LockSupport.html#park()),
 and the documentation for `LockSupport` explicitly says "Reliable usage 
requires the use of volatile (or atomic) variables to control when to park or 
unpark. Orderings of calls to these methods are maintained with respect to 
volatile variable accesses, but not necessarily non-volatile variable accesses."

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13815#discussion_r1187264285

Reply via email to