RFR: 8307483: New micros for j.u.c.LockSupport

David Holmes dholmes at openjdk.org
Tue May 9 02:29:23 UTC 2023


On Tue, 9 May 2023 02:23:51 GMT, David Holmes <dholmes at 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


More information about the core-libs-dev mailing list