If true
, Tomcat attempts to null out any static or final fields from loaded classes when a web application is stopped as a work around for apparent garbage collection bugs and application coding errors.
There have been some issues reported with log4j when this option is true
.
Applications without memory leaks using recent JVMs should operate correctly with this option set to false
.
If not specified, the default value of true
will be used.
public class LogThread extends Thread {
private static volatile boolean stopped;
private final StatisticsLogger statsLogger;
public LogThread(String loggerName, Config config) {
statsLogger = new FileLogger(loggerName, config);
}
public void run() {
while(!LogThread.stopped) {
try {
//do something
} catch (Exception ex) {
logger.error("Exception when logging data", ex);
}
}
statsLogger.shutdown();
}
public static final void shutdown() {
stopped = true;
}
}
Shutdown 在关闭中成为null,会抛出null point exception.