fix: not shutting down executor service after game launched.

This commit is contained in:
huanghongxun
2020-03-31 21:54:00 +08:00
parent cbc85dd99e
commit d00b269786
3 changed files with 7 additions and 3 deletions

View File

@@ -507,12 +507,14 @@ public final class LauncherHelper {
});
break;
case HIDE:
launchingLatch.countDown();
Platform.runLater(() -> {
// If application was stopped and execution services did not finish termination,
// these codes will be executed.
if (Controllers.getStage() != null) {
Controllers.getStage().close();
launchingLatch.countDown();
Controllers.shutdown();
Schedulers.shutdown();
}
});
break;

View File

@@ -288,12 +288,14 @@ public class CancellableTaskExecutor extends TaskExecutor {
@Override
public void run() {
String oldName = Thread.currentThread().getName();
try {
if (task.getName() != null)
Thread.currentThread().setName(task.getName());
if (!executeTask(parentTask, task))
success.set(false);
} finally {
Thread.currentThread().setName(oldName);
latch.countDown();
}
}

View File

@@ -74,10 +74,10 @@ public final class Schedulers {
Logging.LOG.info("Shutting down executor services.");
if (CACHED_EXECUTOR != null)
CACHED_EXECUTOR.shutdownNow();
CACHED_EXECUTOR.shutdown();
if (IO_EXECUTOR != null)
IO_EXECUTOR.shutdownNow();
IO_EXECUTOR.shutdown();
}
public static Future<?> schedule(Executor executor, Runnable command) {