how to identify java code where a thread is started when we have thread name in application log

StackOverflow https://stackoverflow.com/questions/21850196

  •  13-10-2022
  •  | 
  •  

Question

I am getting below log in my old application , i tried to search with .setName as we set thread name using thread.setName method but not able to see it. i doubt it is started by application and i am searching in all .java files.

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.

Not able to understand where these threads( Control and MultiThreadedHttpConnectionManager ) are getting started so that i can modify code to stop these threads.

Edit: My Colleague answered one part of it , MultiThreadedHttpConnectionManager was BUG in Axis2

When i run tomcat in debug mode i see some daemon threads and two other threads (main,Control). Command line arguments for Control thread are showing "org.apache.catalina.startup.Bootstrap start". Looks like tomcat is starting this thread, but if this is the case why tomcat will give error log for this?

Was it helpful?

Solution

I got my answer and 2 simple solutions to this problem

  1. use Kill -QUIT pid to get thread dump and see the stack trace , it gives stack trace and tells what exactly the runnable/Thread class name is.
  2. The other option is to start application in eclipse see get information from debug mode. Where we can see what all threads are running.

OTHER TIPS

If your thread is run through ThreadPoolExecutor::runWorker, you can put a conditional breakpoint there on task.run() with the condition wt.name.equals("my-thread-name") and step into the code that created the thread.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top