On Mon, 14 Oct 2024 13:59:58 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:
>> test/jdk/javax/swing/JButton/bug4323121.java line 58: >> >>> 56: private static final CountDownLatch mouseEntered = new >>> CountDownLatch(1); >>> 57: >>> 58: // Thread-safe by using the mouseEntered latch >> >> Comment may be put before `private static final CountDownLatch mouseEntered >> = new CountDownLatch(1);` > > Why? > > This comment is meant for the `modelArmed` flag. The way it's used now is > thread-safe because of using `mouseEntered`, specifically a value is written > to the flag before `mouseEntered.countDown()` is called, and its value is > read after `mouseEntered.await` returns. > > If any of the above is modified, the `modelArmed` flag may become not > thread-safe and require some kind of synchronisation. Ok.. I misunderstood `mouseEntered` flag, thought the comment is for `CountDownLatch` object. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21475#discussion_r1799703931