该应用程序有四个 javafx fxml 屏幕:登录、主页、个人资料和功能。登录完成后,在各个屏幕中会创建大量工作线程。当用户注销时,除Javafx-Application-Thread之外的所有工作线程都应被取消。
最佳答案
管理工作线程的一个便捷方法是使用 the Executor framework .
示例:
ExecutorService executorService = Executors.newFixedThreadPool(2);
// submit your JavaFX tasks and services
executorService.shutdown();
//executorService.shutdownNow();
有关 Java 和 JavaFX 并发性的更多信息:
关于java - 如何杀死Javafx中的所有/特定后台线程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18796268/