Reputation: 872
The JavaFX Application Thread. Sources I can find says all updates on nodes must happen in this thread.
I am trying to find the documentation for this and if there are any exceptions to this rule. https://docs.oracle.com/javase/8/javafx/interoperability-tutorial/concurrency.htm As it says:
The JavaFX scene graph, which represents the graphical user interface of a JavaFX application, is not thread-safe and can only be accessed and modified from the UI thread also known as the JavaFX Application thread.
https://docs.oracle.com/javase/8/javafx/get-started-tutorial/jfx-architecture.htm#A1107438
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.
I have experienced that not all updates on a node must be done on the JavaFX AT. Some calls to update the node works fine outside this thread. For instance updating Text textProperty does not require running within the JavaFX AT. Nor thus it looks like setting tooltip does either, or changing visibility/disable/managed.
Updates on Label textProperty outside of the JavaFX AT will throw an
IllegalStateException: Not on FX application thread; currentThread = Task
Upvotes: 1
Views: 716
Reputation: 209358
You are confusing what is not allowed with what throws exceptions. Just because something doesn't throw an exception doesn't mean it is allowed, or that it is safe, or that it is guaranteed to work.
All changes to nodes that are part of a live scene graph must happen on the JavaFX Application Thread.
JavaFX makes a best effort to throw exceptions if this rule is violated. Checking the thread costs time, and for some operations the performance cost of checking the thread is too high, so not all violations of the rule will result in an exception. However, violating the rule is prone to inconsistent behavior at arbitrary times in the future, even if no exception is thrown. See Moving circle randomly disappears (javafx) for an example of this happening in practice.
Upvotes: 5