Stop threads before close my JavaFX program

后端 未结 5 1151
迷失自我
迷失自我 2020-12-14 17:05

I\'m having a problem with closing my application because some threads are still running after I close the application. Somebody can help me with some method to stop all Th

5条回答
  •  佛祖请我去吃肉
    2020-12-14 18:03

    Better way to fix this is add the EventHandler on Close Request:

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setOnCloseRequest(new EventHandler() {
           @Override
           public void handle(WindowEvent e) {
              Platform.exit();
              System.exit(0);
           }
        });
    }
    

提交回复
热议问题