I have a question about multi-threading and the binding of a StringProperty.
I have a class CacheManager
, which contains a Thread
which updates my cache with the changes on the server. Now, I want to notify the user with a text and percentage of the progress (which are a Label
and ProgressBar
in JavaFX). I use public static DoubleProperty
and StringProperty
for this, which are defined in the CacheManager
class. I just bind it like this:
progressBar.progressProperty().bind(CacheManager.progress);
someLabel.textProperty().bind(CacheManager.status);
Now, in the Updater thread, I update these Properties
. With DoubleProperty
this works just fine, and the ProgressBar
is showing the progress perfectly. However, updating the Label
with the status (which is the text from the StringProperty
) throws an error: java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-9
Now, my question is: Why does the DoubleProperty
work just fine, while the StringProperty
throws an error? What is the difference between them considering multi-threading?
Any ideas on a redesign are also welcome and any help is greatly appreciated!