boost priority of shutdown thread

This commit is contained in:
zzz
2012-09-10 17:25:00 +00:00
parent 3781928693
commit 835ed6d9bb
2 changed files with 5 additions and 0 deletions

View File

@@ -766,6 +766,9 @@ public class Router implements RouterClock.ClockShiftListener {
* NOT to be called by others, use shutdown().
*/
public void shutdown2(int exitCode) {
// help us shut down esp. after OOM
int priority = (exitCode == EXIT_OOM) ? Thread.MAX_PRIORITY - 1 : Thread.NORM_PRIORITY + 2;
Thread.currentThread().setPriority(priority);
_shutdownInProgress = true;
_log.log(Log.CRIT, "Starting final shutdown(" + exitCode + ')');
// So we can get all the way to the end

View File

@@ -18,6 +18,8 @@ public class OOMListener implements I2PThread.OOMEventListener {
}
public void outOfMemory(OutOfMemoryError oom) {
// boost priority to help us shut down
Thread.currentThread().setPriority(Thread.MAX_PRIORITY - 1);
Router.clearCaches();
Log log = _context.logManager().getLog(Router.class);
log.log(Log.CRIT, "Thread ran out of memory, shutting down I2P", oom);