我正在一个web应用程序中工作。我需要显示与Web应用程序和每个线程信息相关的所有线程。我曾尝试以下方法如何在java中获取特定web应用程序的线程信息?
for (Thread thread : Thread.getAllStackTraces().keySet()) {
// get the required thread information
// is alive
// is daemon
// get name
// thread.getThreadGroup().getName()
// etc
}
该方法的问题在于它给出了部署在服务器(Tomcat)中的所有线程信息。但我需要仅与此Web应用程序关联的线程。任何帮助将是可观的。
线程不与web应用程序关联。线程用于处理由Tomcat实例加载的所有webapps的传入请求。他们是共享的。 – Andreas