Access a method that is out of thread

2

I have a video running in my application and a Thread running a Socket (server), all within the same class, but I need this Thread to access a method that is outside of it.

To be more exact I want to run getCurrentTime () to get the current time the video is running and send it via Socket to another application.

    
asked by anonymous 16.05.2017 / 19:59

1 answer

1

To get access to the UI you should ask the UI API to execute a certain code on the UI thread, in case JavaFX follows the excerpt below.

Platform.runLater(new Runnable() {
    @Override public void run() {
        //Acessar componente de vídeo aqui    
    }
});

or in Java 8

 Platform.runLater(() -> {
       //Acessar componente de vídeo aqui    
 }));

The detail is that this code will run when the JavaFX API finds it better.

    
17.05.2017 / 12:29