Java examples for JavaFX:JavaFX Thread
run Safe thread in JavaFX
//package com.java2s; import java.util.Objects; import javafx.application.Platform; public class Main { public static void runSafe(final Runnable runnable) { Objects.requireNonNull(runnable, "runnable"); if (Platform.isFxApplicationThread()) { runnable.run();// w ww. j a va2 s . c om } else { Platform.runLater(runnable); } } }