I have an application which performs a long-running computation. The obvious thing to do is move this into a different thread. However I'm not quite sure how to do that in JavaFX, specifically how the threads can interact.
1) When I run the computation on the application thread, if I set the text of a label to e.g. "Starting computation..."
before I start the computation, the label will not be updated before
after the computation has finished. If the rendering is done in a seperate thread from the application thread, why doesn't it update the UI immediately?
2) How can I use the concurrent features of JavaFX (Service, Worker, Task) to perform the computation in a background thread?
3) How can I update the UI
from the background thread (e.g. updating a progress bar)? The doc says:
JavaFX application thread: This is the primary thread used by JavaFX application developers. Any “live” scene, which is a scene that is part of a window, must be accessed from this thread.
What's the meaning of "access" here? Does it mean that I cannot call any methods on UI elements from other threads than the application thread?