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

Aleksey Shipilev shade at openjdk.org
Mon May 8 09:26:32 UTC 2023


On Mon, 8 May 2023 05:58:26 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> test/micro/org/openjdk/bench/java/util/concurrent/UnparkBenchSleepersAfter.java line 131:
>> 
>>> 129:         public void run() {
>>> 130:             my_thread = Thread.currentThread();
>>> 131:             while (!done) {
>> 
>> You might want to re-check IdleThread. From a quick look I would have expected "done" to be volatile. Also "my_thread" as it is set in the run with plain access.
>
> 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.

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

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


More information about the core-libs-dev mailing list