RFR: 8369306: Implement invokeAndWait and finishTerminating on headless platform [v3]
Andy Goryachev
angorya at openjdk.org
Mon Oct 13 17:13:14 UTC 2025
On Mon, 13 Oct 2025 16:51:54 GMT, Johan Vos <jvos at openjdk.org> wrote:
>> Can this variable be accessed by two threads where one of them doesn't synchronize some other way? If so, then Andy has a point.
>
> I'm aware of the purpose of volatile :)
> However, I'm also aware of the cost of volatile, hence I prefer not to do it unless I know there is a possible scenario where it is needed.
> That is why I'm asking the same question as the one asked by Kevin.
I know you do - the links were added for sake of others :-)
The answer to your question is - I don't know. If one can guarantee that there is only one thread accessing it, we may need to add a comment (though things might change in the future, and no one reads comments elsewhere in the code). And if not, then some form of synchronization is mandatory.
I prefer not to think though, and make sure we don't plant booby traps in the code.
BTW, what is the cost of volatile? 0.1 ns? ;-)
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1934#discussion_r2426890844
More information about the openjfx-dev
mailing list