Tomcat 6 memory leaks log entries

前端 未结 3 1468
忘掉有多难
忘掉有多难 2020-12-29 14:23

Below is outtake of unique entries in my Catalina.out file on CentOS machine. I\'m running Tomcat 6 with spring 3 and my application. There is whole bunch of them so I just

3条回答
  •  心在旅途
    2020-12-29 15:06

    Set up a Servlet to manage this in its destroy() method. The threads can check a flag to see if they must continue or not.

    In your servlet, do the following in the destroy method. You will obviously need to be able to have access to a Collection but how you get that really depends on how your system is set up.

    destroy() {
        for (MyThread thread : myThreads) {
            thread.stopProcessing();
        }
    }
    

    Your MyThread class will have something like this:

    public class MyThread {
        private boolean finished = false;
    
        @Override
        public void run() {
            while (!finished) {
                //do something
            }
        }
    
        public void stopProcessing() {
            finished = true;
        }
    }
    

提交回复
热议问题