Class FXWorker

java.lang.Object
org.jhotdraw8.fxbase.concurrent.FXWorker

public class FXWorker extends Object
FXWorker provides convenience methods for executing CheckedRunnable objects on a
Author:
Werner Randelshofer
  • Method Details

    • run

      public static CompletableFuture<Void> run(CheckedRunnable runnable)
      Calls the runnable on a new Thread. The completion stage is completed on the FX Application Thread.
      Parameters:
      runnable - the runnable
      Returns:
      the CompletableFuture
    • run

      public static CompletableFuture<Void> run(Executor executor, CheckedRunnable runnable)
      Calls the runnable on the executor thread. The completion stage is completed on the FX Application Thread.
      Parameters:
      executor - the executor, if null then a new thread is created
      runnable - the runnable
      Returns:
      the CompletableFuture
    • supply

      public static <T> CompletableFuture<T> supply(Callable<T> supplier)
      Calls the supplier on a thread of the common fork join pool. The completion stage is completed on the FX Application Thread.
      Type Parameters:
      T - the value type
      Parameters:
      supplier - the supplier
      Returns:
      the CompletableFuture
    • supply

      public static <T> CompletableFuture<T> supply(Executor executor, Callable<T> supplier)
      Calls the supplier on the executor thread. The CompletableFuture is completed on the FX Application Thread.
      Type Parameters:
      T - the value type
      Parameters:
      executor - the executor
      supplier - the supplier
      Returns:
      the CompletableFuture
    • work

      public static <T> CompletableWorker<T> work(Executor executor, CheckedFunction<WorkState<T>,T> supplier, WorkState<T> workState)
      Calls the supplier on the executor thread. The CompletableWorker is completed on the FX Application Thread.
      Type Parameters:
      T - the value type
      Parameters:
      executor - the executor
      supplier - the supplier
      Returns:
      the CompletableWorker