In my program some threads are created and given a Task
that ends (so that thread should die), and I also have a Executors.newSingleThreadScheduledExecutor
and Executors.newSingleThreadExecutor
, I noticed that if I press a close button that I made:
@FXML private void handleExit(){
gameManager.cleanup();
Stage stage = (Stage)menuBarTopMenu.getScene().getWindow();
Platform.exit();
stage.close();
}
I don't get the Process finished with exit code 0
in intelij.
So I even set those threads I mentioned to daemons and this is the cleanup:
public void cleanup(){
updateTime.shutdown(); // it's Executors.newSingleThreadScheduledExecutor
updateTime.shutdownNow();
}
But I still don't see the successful exit. Could it be because I didn't shut down the Executors.newSingleThreadExecutor
? I couldn't find a way to shut it down.
What other cleanup I should do?