Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8u45
    • Fix Version/s: tbd
    • Component/s: javafx
    • Environment:

      JDK 8u45, Win 8.1, 64 Bit

      Description

      Thanks to Java SE 8's CompletableFuture it is possible to do low-level reactive programming style in Java. With JavaFX this is a bit cumbersome, as there is not Executor for JavaFX.

      I like to propose to add the following code to the Platform class:

      ```
      public static final Executor JAVA_FX = Platform::runAsJavaFX;

      public static final void runAsJavaFX(final Runnable runnable) {
      if (Platform.isFxApplicationThread())
      runnable.run();
      else
      Platform.runLater(runnable);
      }
      ```

      This makes it pretty simple and readable to use CompletableFuture with Java FX, hence allowing totally simple background tasks done by the Java SE's shared thread pool:

      ```
      CompletableFuture.supplyAsync(backgroundTask).thenAcceptAsync(javaFxTask, JAVA_FX);
      ```

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mkarg Markus Karg
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: