JavaFX Application Thread as daemon thread on macOS

José Pereda jose.pereda at gluonhq.com
Tue Dec 16 10:57:57 UTC 2025


When running test suites, there are scenarios where each test must wait
until the JavaFX shutdown has fully completed before the next one begins.

Currently, there is no dedicated API to determine when shutdown is
complete. Developers often rely on workarounds, such as sleep times or
inspecting Thread.getAllStackTraces() to verify that no JavaFX threads
remain alive. For instance, this approach was used for
userThreadIsShutdownOnPlatformExitTest in HeadlessApplication2Test
(JDK-8369306):

assertFalse(Thread.getAllStackTraces().keySet().stream().anyMatch(t ->
"JavaFX Application Thread".equals(t.getName())));

Starting with JavaFX 24 (JDK-8339178), the JavaFX Application Thread was
changed from a non-daemon to a daemon thread on macOS. While this may not
impact most use cases, it might affect the testing context described above.
In fact, if userThreadIsShutdownOnPlatformExitTest is run headfully it will
fail on macOS, but work on the other platforms.

What is the recommended approach for this specific use case? Should a
reliable API be introduced to monitor this state?

-- 
Jose
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20251216/7cbf5355/attachment.htm>


More information about the openjfx-dev mailing list