run Safe thread in JavaFX - Java JavaFX

Java examples for JavaFX:JavaFX Thread

Description

run Safe thread in JavaFX

Demo Code


//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);
        }
    }
}

Related Tutorials