Search code examples
multithreadingconcurrencyjavafx-2java.util.concurrent

Do i need to call Platform.runLater for updating UI if i'm working on JavaFX Application Thread


Do i need to create a new Runnable object and run Platform.runLater if i'm still working on JavaFX Application Thread for updating UI. For example, i need to update a Text object which is imported in Controller Class from a fxml file, and i will call a static method from another class to do this. Moreover, the imported Text object is static, so is it safe to call static object like;

ControllerClass.textLabel.setText("foobar");

or even if i'm working on JavaFX Application Thread, should using Platform.runLater will be more safe for updating UI ?


Solution

  • No.

    You do not need to use Platform.runLater if you are already in the JavaFX application thread.