This content has been marked as final. Show 1 reply
Using Platform.runLater to visualise your background process is fine.
The couple of things you need to be careful of are:
1. Never read or write the active scenegraph objects or trigger a bind change on those objects from your background process.
2. Don't call Platform.runLater so often that you end up overloading the JavaFX event system.
You might also want to take a look at the Task and Service interfaces. These encapsulate background processes to provide APIs for threadsafe feedback of messages, progress and return values. Here is a sample of using a Task: https://gist.github.com/2305098 and another one of using a service: https://gist.github.com/2774476.
The Task and Service javadoc has lots of good (though incomplete) examples:
The JavaFX documentation provides some background info on when you might want to use the different concurrency options provided by JavaFX:
In general if the task is not really managed by or kicked off from the UI, then Platform.runLater is probably the way to go (e.g. responding to a push message from a server such as a temperature update from a sensor), otherwise use the Task and Service interfaces (e.g. if the user clicked on a button to initiate a call/response message to a server such as initiating a google search and collecting the search response).