forked from I2P_Developers/i2p.i2p
boost priority of shutdown thread
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user