Fix wrong thread at shutdownhook

This commit is contained in:
Manfred Karrer 2016-07-17 13:03:12 +02:00
parent 6f641bff1c
commit a4573208b4
3 changed files with 7 additions and 14 deletions

View File

@ -67,17 +67,9 @@ public class FileManager<T> {
saveNowInternal(serializable); saveNowInternal(serializable);
return null; return null;
}; };
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
Runtime.getRuntime().addShutdownHook(new Thread() { UserThread.execute(FileManager.this::shutDown);
@Override }, "FileManager.ShutDownHook"));
public void run() {
try {
FileManager.this.shutDown();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
} }

View File

@ -119,8 +119,9 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
openOffers.forEach(e -> e.getOffer().setPriceFeed(priceFeed)); openOffers.forEach(e -> e.getOffer().setPriceFeed(priceFeed));
// In case the app did get killed the shutDown from the modules is not called, so we use a shutdown hook // In case the app did get killed the shutDown from the modules is not called, so we use a shutdown hook
Runtime.getRuntime().addShutdownHook(new Thread(OpenOfferManager.this::shutDown, Runtime.getRuntime().addShutdownHook(new Thread(() -> {
"OpenOfferManager.ShutDownHook")); UserThread.execute(OpenOfferManager.this::shutDown);
}, "OpenOfferManager.ShutDownHook"));
} }
public void onAllServicesInitialized() { public void onAllServicesInitialized() {

View File

@ -359,7 +359,7 @@ public class BitsquareApp extends Application {
log.info("App shutdown complete"); log.info("App shutdown complete");
System.exit(0); System.exit(0);
}); });
}, 100, TimeUnit.MILLISECONDS); }, 200, TimeUnit.MILLISECONDS);
} }
private void gracefulShutDown(ResultHandler resultHandler) { private void gracefulShutDown(ResultHandler resultHandler) {