Java tutorial
//package com.java2s; /* * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ import javafx.application.Platform; public class Main { /** * If called from the FX Application Thread * invokes a runnable directly blocking the calling code * Otherwise * uses Platform.runLater without blocking */ static void runOnFxThread(Runnable runnable) { if (Platform.isFxApplicationThread()) { runnable.run(); } else { Platform.runLater(runnable); } } }