Why Thread.sleep() doesn't work accordingly in JavaFX?
问题 When i am using JavaFX, the sleep function won't work accordingly. Like in this code: public class Controller { @FXML private Label label; @FXML private Button b1; public void write() throws InterruptedException { label.setText("FIRST TIME"); for(int i=1;i<=5;i++) { System.out.println("Value "+i); label.setText("Value "+i); Thread.sleep(2000); } label.setText("LAST TIME"); } when the Button b1 is pressed the write function is called. Now, in the console "Value + i" is being printed after 2