org.apache.catalina.loader. WebappClassLoader.ENABLE_CLEAR_REFERENCES

原创 2010年10月08日 14:46:00

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.

内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:org.apache.catalina.loader. WebappClassLoader.ENABLE_CLEAR_REFERENCES
举报原因:
原因补充:

(最多只允许输入30个字)