RFR: 8306137: Open source several AWT ScrollPane related tests [v2]
Alexey Ivanov
aivanov at openjdk.org
Thu Apr 27 12:52:53 UTC 2023
On Wed, 26 Apr 2023 16:45:57 GMT, Tejesh R <tr at openjdk.org> wrote:
>> test/jdk/java/awt/ScrollPane/ScrollPaneRemoveAdd.java line 121:
>>
>>> 119: volatile boolean state = false;
>>> 120: Object lock = new Object();
>>> 121: volatile int waiting = 0;
>>
>> Why are both `state` and `waiting` marked as volatile? Either is accessed from synchronized blocks protected by `lock` except for `getState` which should also use the `lock` object.
>
> I don't think its required to be volatile, not sure.
They shouldn't be volatile, a proper synchronisation is used. But `getState` should use `lock` lock to return the state because access to `state` is synchronised using `lock`, not `this`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13621#discussion_r1179096063
More information about the client-libs-dev
mailing list