Enabling Glass thread checks

John Smith John_Smith at symantec.com
Fri Oct 4 11:45:48 PDT 2013

> IllegalStateException("This operation is permitted on the event thread only")

What is the event thread?

Current warnings about thread rule violations appear to be something like below (from: http://stackoverflow.com/questions/12182592/javafx-2-x-swing-not-on-fx-application-thread):

   Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Not on FX application thread; currentThread = AWT-EventQueue-0

It is very confusing if warnings about what thread you should be on might use different names for what is perhaps the same thing.

If I do System.out.println(Thread.currentThread().getName()); in a start() method, I get:

  JavaFX Application Thread

The JavaFX Architecture overview (http://docs.oracle.com/javafx/2/architecture/jfxpub-architecture.htm#A1107438) only mentions these threads:

    JavaFX application thread: This is the primary thread used by JavaFX application developers. Any "live" scene, which is a scene that is part of a window, must be accessed from this thread. A scene graph can be created and manipulated in a background thread, but when its root node is attached to any live object in the scene, that scene graph must be accessed from the JavaFX application thread. This enables developers to create complex scene graphs on a background thread while keeping animations on 'live' scenes smooth and fast. The JavaFX application thread is a different thread from the Swing and AWT Event Dispatch Thread (EDT), so care must be taken when embedding JavaFX code into Swing applications.

    Prism render thread: This thread handles the rendering separately from the event dispatcher. It allows frame N to be rendered while frame N +1 is being processed. This ability to perform concurrent processing is a big advantage, especially on modern systems that have multiple processors. The Prism render thread may also have multiple rasterization threads that help off-load work that needs to be done in rendering.

    Media thread: This thread runs in the background and synchronizes the latest frames through the scene graph by using the JavaFX application thread.

-----Original Message-----
From: openjfx-dev-bounces at openjdk.java.net [mailto:openjfx-dev-bounces at openjdk.java.net] On Behalf Of Petr Pchelko
Sent: Friday, October 04, 2013 1:40 AM
To: OpenJFX list
Subject: Enabling Glass thread checks

Hello, OpenJFX.

FX is a single threaded UI toolkit. Glass (the underlying native window toolkit portability layer for FX) is being changed to ensure it is accessed from the UI thread. You can follow progress in https://javafx-jira.kenai.com/browse/RT-26891

We are reenabling the Glass thread checks ones again. Previous attempts failed, because we've been finding some threading issues, however now all the threading issues have been fixed and we are in a good state to switch on the checks again.

The following exception would mean that you've hit a thread check: IllegalStateException("This operation is permitted on the event thread only"). 
In that case please check your threading and if everything seems correct - please contact the Glass team.

Thank you.
With best regards. Petr.

More information about the openjfx-dev mailing list