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);
return null;
};
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
FileManager.this.shutDown();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
UserThread.execute(FileManager.this::shutDown);
}, "FileManager.ShutDownHook"));
}

View File

@ -119,8 +119,9 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
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
Runtime.getRuntime().addShutdownHook(new Thread(OpenOfferManager.this::shutDown,
"OpenOfferManager.ShutDownHook"));
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
UserThread.execute(OpenOfferManager.this::shutDown);
}, "OpenOfferManager.ShutDownHook"));
}
public void onAllServicesInitialized() {

View File

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