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; break;
case HIDE: case HIDE:
launchingLatch.countDown();
Platform.runLater(() -> { Platform.runLater(() -> {
// If application was stopped and execution services did not finish termination, // If application was stopped and execution services did not finish termination,
// these codes will be executed. // these codes will be executed.
if (Controllers.getStage() != null) { if (Controllers.getStage() != null) {
Controllers.getStage().close(); Controllers.getStage().close();
launchingLatch.countDown(); Controllers.shutdown();
Schedulers.shutdown();
} }
}); });
break; break;

View File

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

View File

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