I need to transmit Strings to Main thread (there is GUI) to add them to javafx' TextFlow.
In the background thread's run()
, reader waits strings from JSch channel. On new stings it must transmit them to main thread. So main thread can't wait data from background thread (as it is GUI thread), and background thread must send some event with new Strings.
Another trouble, that in application can be, for example, 4 background threads, that reads some data from JSch channel and send it to one window to show.
To transmit data to the GUI thread,use
Platfotm.runLater()
methodPlatform.runLater
makes you modify the GUI thread from other threads, It has a swing equivalent ofSwingUtilities.invokeLater