Short answer
start() changed() "JavaFX Application Thread". , . Runnable.run(), , start() "JavaFX Application Thread" - : start() , . ( / , , .)
.
( ):
public void start(Stage stage) throws Exception {
System.out.println("2: " + Thread.currentThread().getName());
...
webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
@Override
public void changed(ObservableValue<? extends State> ov, State t, State t1) {
if (t1 == Worker.State.SUCCEEDED) {
System.out.println("3: " + Thread.currentThread().getName());
System.out.println("Z");
}
}
});
webView.getEngine().load("...");
System.out.println("A");
Thread.sleep(2000);
System.out.println("B");
Thread.sleep(2000);
}
public static void main(String[] args) {
System.out.println("1: " + Thread.currentThread().getName());
launch(args);
System.out.println("4: " + Thread.currentThread().getName());
}
:
:
: :
1: main
2: JavaFX Application Thread
: ... ! ? "Thread Application" JavaFX, , sleep() -ing, "A".
: "" 2
: "B", -
: "B" 2
: , ; sleep(), .
, , , start() , launch() , , . :
:
3: JavaFX Application Thread
Z
:
:
4: main
: ,
, main() start() .
: sleep() - , , , .