void () { while (true) { Runnable task = getNextTask(); if (task == null) break; // task can change myShutdownTasks try { task.run(); } catch (Throwable e) { try { Logger.getInstance(ShutDownTracker.class).error(e); } catch (AssertionError ignore) { // give a chance to execute all shutdown tasks in tests } } } }