I am trying to run the background thread of a JavaFX application periodically, which changes some GUI properties.
I think I know how to use the Task and Service classes from javafx.concurrent and cannot figure out how to run such a periodic task without using the Thread#sleep() method. It would be nice if I could use some of the methods Executor from Executors ( Executors.newSingleThreadScheduledExecutor() )
I tried to run Runnable every 5 seconds, which restarts javafx.concurrent.Service , but it hangs immediately when service.restart or even service.getState() called.
So, I use Executors.newSingleThreadScheduledExecutor() , which runs my Runnable every 5 seconds and that Runnable starts another Runnable using:
Platform.runLater(new Runnable() {
This looks very unpleasant :( Is there a better way to do this using Task or Service classes?
javafx-2
Michał Króliczek Apr 01 2018-12-12T00: 00Z
source share