in tomcat,if a webapp did stop a none daemon thread,tomcat can not be shutdown by shutdown.sh
for example:
public class demo implements ServletContextListener{
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
// yes,we can cancel timer in here,but this is not the major problem
}
public void contextInitialized(ServletContextEvent arg0) {
Timer timer = new Timer();
timer.schedule(new Test(), 1000, 1000*10);
}
}
public class Test extends TimerTask{
@Override
public void run() {
System.out.println("AAAA");
}
}
like as above,tomcat can not be shutdown by shutdown.sh. from jvisualvm,threads inspector say:
"Timer-0" - Thread t@40
java.lang.Thread.State: TIMED_WAITING
at java.lang.Object.wait(Native Method)
- waiting on <3957edeb> (a java.util.TaskQueue)
at java.util.TimerThread.mainLoop(Timer.java:552)
at java.util.TimerThread.run(Timer.java:505)
Locked ownable synchronizers:
- None
stack info did not point out which java class created the thread, my question is how to find out who created the thread from many webapps.
Thanks!