-2
Every time I click the button, in an attempt to start the chronometer, this error happens:
Exception in thread "Thread-4" java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-4
referring to that code line : `
lblMainChronometer.setText(String.format("%02d:%02d:%02d.%02d", hours, minutes, seconds, secondsHundredth));
This is the Fxmldcumentcontroler of my program :
package chronometer;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
public class FXMLDocumentController implements Initializable {
    
    @FXML    
    private Label lblMainChronometer;
    private static int startTime;
    
    private void startCounter() { startTime = (int) System.currentTimeMillis(); }
    
    private static int currentTimeHundredth() {
        double currentTimeMillis;
        currentTimeMillis = startTime - System.currentTimeMillis();
        int currentTimeHundreth = (int) Math.floor(currentTimeMillis / 10);
        return currentTimeHundreth; 
    }
    
    private Runnable mainChronometer = new Runnable() {
        @Override
        public void run() {
            while (true) {
                
                int secondsHundredth = currentTimeHundredth() % 100;
                int currentTimeSeconds = currentTimeHundredth() - secondsHundredth;
                int seconds = (int) (currentTimeSeconds % 60);
                int minutes = (int) (currentTimeSeconds / 60);
                minutes %= 60; // to stay just the minutes (excluding the hours)           
                int hours = (int) (minutes / 60);
                lblMainChronometer.setText(String.format("%02d:%02d:%02d.%02d", hours, minutes, seconds, secondsHundredth));
                
            }
        }
    };
          
    @FXML
    private void handleButtonAction(ActionEvent event) throws InterruptedException {
        
        startCounter();
        new Thread(mainChronometer).start();
    }
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        
    }    
    
}
Help me out, please!!!