DataFX: ObservableExecutor Preview
Since December we are working on a new DataFX version. DataFX will provide a new low level API for multithreading and background tasks in JavaFX. With this API everyone can create new and custom DataSources that will fetch data in background and publish it to JavaFX properties (like you can do with the SwingWorker in Swing). Additionally we will provide some basic concurrency features like the invokeAndWait-method.
Next to this features we created a new Executor class that offers some additional features for the use with JavaFX. The
ObservableExecutor holds a ListProperty with all currently scheduled or running tasks. By using this Property you can easily observe all tasks in your UI. We will provide a ListCell class to visualize the running tasks of the executor with only a few lines of code:
The ObservableExecutor uses the wrapper pattern to hold any Executor. Because all task are wrapped into Services you can easily access the title, message or progress of any task. A short example that shows the current state of the API can be found here:
Because Runnable & Callable normally do not provide title, message and progress properties we created extended interfaces (
DataFXCallable) where all this functions are injected while using them with the ObservableExecutor.
At the current state tasks can be passed to an
ObservableExecutor by the following methods:
There are some additional features, too. You can mark a task as not cancelable for example.
Hope you like this stuff!