Identify the oldest thread in a Java stack trace

I am considering dumping Java threads when part of my application (deployed on JBoss 4.2.3) was blocked due to blocking database queries. There are 6 threads, all of which fulfill various requests, and I want to determine who was the first, as this will be a candidate for the original cause.

Can I compare the total processor time and user time in each thread and treat the thread with the highest time as the oldest (first to start)? Or can different threads of different amounts of time be allocated?

For example (simple example)

Thread ajp-0.0.0.0-8009-19 (Id = 21) RUNNABLE Total CPU time 100000 ms, User time 100000 ms stack here... Thread ajp-0.0.0.0-8009-19 (Id = 200) RUNNABLE Total CPU time 200000 ms, User time 200000 ms stack here... Thread ajp-0.0.0.0-8009-19 (Id = 2590) RUNNABLE Total CPU time 300000 ms, User time 300000 ms < --- THIS THREAD MUST HAVE STARTED BEFORE OTHERS stack here... 
+4
source share
1 answer

Total processor time or Total user time does not give you any information about the thread age. He can only say that the age of the thread at the minimum is a value.

You can use a thread dump analyzer like Mchr3k - Java Thread Dump Analyzer or Samurai

+1
source

All Articles