I have a thread that check the network connection and change a static field.
and I have another thread that have a infinity loop inside it (like below):
Task task = new Task<Void>() {
protected Void call() {
int status = 0;
while(true) {
// System.out.println("status = " + status);
if (status == mNetwork.status) continue;
status = mNetwork.status;
Platform.runLater(() -> {
lbl.setText("status : " + status);
});
}
}
};
new Thread(task).start();
But I don't know why it only works when I add a print function (the commented line) or create a breakpoint and debug the app. any body knows what's the problem?