fix: game is blocked for launching

This commit is contained in:
huanghongxun
2020-04-17 00:15:34 +08:00
parent f84c4310f9
commit 1eeba344f7
2 changed files with 6 additions and 3 deletions

View File

@@ -106,7 +106,6 @@ public final class Launcher extends Application {
Schedulers.shutdown(); Schedulers.shutdown();
Controllers.shutdown(); Controllers.shutdown();
Platform.exit(); Platform.exit();
Lang.executeDelayed(OperatingSystem::forceGC, TimeUnit.SECONDS, 5, true);
}); });
} }

View File

@@ -73,11 +73,15 @@ public final class Schedulers {
public static synchronized void shutdown() { public static synchronized void shutdown() {
Logging.LOG.info("Shutting down executor services."); Logging.LOG.info("Shutting down executor services.");
// shutdownNow will interrupt all threads.
// So when we want to close the app, no threads need to be waited for finish.
// Sometimes it resolves the problem that the app does not exit.
if (CACHED_EXECUTOR != null) if (CACHED_EXECUTOR != null)
CACHED_EXECUTOR.shutdown(); CACHED_EXECUTOR.shutdownNow();
if (IO_EXECUTOR != null) if (IO_EXECUTOR != null)
IO_EXECUTOR.shutdown(); IO_EXECUTOR.shutdownNow();
} }
public static Future<?> schedule(Executor executor, Runnable command) { public static Future<?> schedule(Executor executor, Runnable command) {