Java examples for JavaFX:JavaFX Thread
run And Wait on JavaFX Thread
//package com.java2s; import java.util.concurrent.FutureTask; import javafx.application.Platform; public class Main { public static void runAndWait(Runnable runnable) { try {/* ww w . j a v a 2s . c o m*/ if (Platform.isFxApplicationThread()) { runnable.run(); } else { FutureTask<Object> futureTask = new FutureTask<>(runnable, null); Platform.runLater(futureTask); futureTask.get(); } } catch (Exception e) { e.printStackTrace(); } } }