多线程当我们在应用程序日志中有线程名时,如何识别java代码中线程的起始位置
在我的旧应用程序中,我的日志越来越少,我试图用它进行搜索。setName,因为我们使用thread设置线程名。setName方法,但无法看到它。我怀疑它是由应用程序启动的,我正在搜索所有。java文件
Jan 30, 2014 1:00:29 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads SEVERE: The web application [/MyWebApp] appears
to have started a thread named [Control] but has failed to stop it.
This is very likely to create a mem ory leak. Jan 30, 2014 1:00:29 AM
org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/MyWebApp] appears to have started a
thread named [MultiThreadedHttpConnectionManager cleanup] but has
failed to stop it.
无法理解这些线程(Control和MultiThreadedHttpConnectionManager)的启动位置,因此我可以修改代码以停止这些线程
编辑:我的同事回答了其中的一部分,多线程HttpConnectionManager在Axis2中是BUG
当我在调试模式下运行tomcat时,我看到一些守护进程线程和另外两个线程(main、Control)。控制线程的命令行参数显示为“org.apache.catalina.startup.Bootstrap start”。看起来tomcat正在启动这个线程,但是如果是这样,为什么tomcat会给出错误日志呢
# 1 楼答案
如果你的线程是通过
ThreadPoolExecutor::runWorker
运行的,你可以在task.run()
上设置一个条件断点,条件是wt.name.equals("my-thread-name")
,然后进入创建线程的代码# 2 楼答案
我得到了这个问题的答案和两个简单的解决方案