On Tue, 9 May 2023 02:23:51 GMT, David Holmes <dhol...@openjdk.org> wrote:
>> 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." > > Irrespective of park/unpark barriers, the JIT should have hoisted `done` and > rewritten as: > > if (!done) { > while(true) { > ... > } > } Well I guess the park/unpark barriers prevented that. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/13815#discussion_r1188053179