RFR: 8369306: Implement invokeAndWait and finishTerminating on headless platform [v3]
Andy Goryachev
angorya at openjdk.org
Mon Oct 13 16:15:42 UTC 2025
On Sat, 11 Oct 2025 09:05:45 GMT, Johan Vos <jvos at openjdk.org> wrote:
>> modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/NestedRunnableProcessor.java line 66:
>>
>>> 64: void stopProcessing() {
>>> 65: for (RunLoopEntry entry : activeRunLoops) {
>>> 66: runnableQueue.add(() -> entry.active = false);
>>
>> I would highly recommend declaring `RunLoopEntry.active` `volatile`.
>
> Can you elaborate on this? What usecase do you see where 2 threads might see different values, leading to problems that could not occur if active was volatile?
generally speaking, when two threads modify a single boolean variable, there might be scenarios, depending on the exact hardware, when the other thread does not see the modified value right away.
some of the comments in
https://stackoverflow.com/questions/65037547/the-volatile-keyword-and-cpu-cache-coherence-protocol
https://stackoverflow.com/questions/106591/what-is-the-volatile-keyword-useful-for
might explain it better.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1934#discussion_r2426770444
More information about the openjfx-dev
mailing list