mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
Safety
This commit is contained in:
@@ -127,9 +127,14 @@ public final class App extends Application {
|
|||||||
|
|
||||||
}, false, "init_loading");
|
}, false, "init_loading");
|
||||||
|
|
||||||
// Start loading assets
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
new Thread(() -> ResourceManager.loadAssets(new ResourceLoader("app/src/main/resources/assets")))
|
try {
|
||||||
.start();
|
executor.submit(
|
||||||
|
() -> ResourceManager.loadAssets(new ResourceLoader("app/src/main/resources/assets")
|
||||||
|
));
|
||||||
|
} finally {
|
||||||
|
executor.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
stage.show();
|
stage.show();
|
||||||
|
|
||||||
@@ -164,7 +169,13 @@ public final class App extends Application {
|
|||||||
|
|
||||||
private void setOnLoadingSuccess(LoadingWidget loading) {
|
private void setOnLoadingSuccess(LoadingWidget loading) {
|
||||||
loading.setOnSuccess(() -> {
|
loading.setOnSuccess(() -> {
|
||||||
|
|
||||||
|
try {
|
||||||
initSystems();
|
initSystems();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
AppSettings.applyMusicVolumeSettings();
|
AppSettings.applyMusicVolumeSettings();
|
||||||
new EventFlow().addPostEvent(new AudioEvents.StartBackgroundMusic()).postEvent();
|
new EventFlow().addPostEvent(new AudioEvents.StartBackgroundMusic()).postEvent();
|
||||||
loading.hide();
|
loading.hide();
|
||||||
@@ -182,12 +193,16 @@ public final class App extends Application {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSystems() { // TODO Move to better place
|
private void initSystems() throws InterruptedException { // TODO Move to better place
|
||||||
|
|
||||||
final int THREAD_COUNT = 2;
|
final int THREAD_COUNT = 2;
|
||||||
CountDownLatch latch = new CountDownLatch(THREAD_COUNT);
|
CountDownLatch latch = new CountDownLatch(THREAD_COUNT);
|
||||||
|
|
||||||
|
@SuppressWarnings("resource")
|
||||||
ExecutorService threads = Executors.newFixedThreadPool(THREAD_COUNT);
|
ExecutorService threads = Executors.newFixedThreadPool(THREAD_COUNT);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
threads.submit(() -> {
|
threads.submit(() -> {
|
||||||
new NetworkingClientEventListener(
|
new NetworkingClientEventListener(
|
||||||
GlobalEventBus.get(),
|
GlobalEventBus.get(),
|
||||||
@@ -223,10 +238,9 @@ public final class App extends Application {
|
|||||||
latch.countDown();
|
latch.countDown();
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
} finally {
|
||||||
latch.await();
|
latch.await();
|
||||||
} catch (InterruptedException e) {
|
threads.shutdown();
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user