毕鹏的专栏

Jeffrey

org.apache.catalina.loader. WebappClassLoader.ENABLE_CLEAR_REFERENCES

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个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭