aspose file tools*
The moose likes Threads and Synchronization and the fly likes New to threading. Help me analyze this excerpt from the dump Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "New to threading. Help me analyze this excerpt from the dump" Watch "New to threading. Help me analyze this excerpt from the dump" New topic
Author

New to threading. Help me analyze this excerpt from the dump

Pappu Kumar
Ranch Hand

Joined: Oct 01, 2002
Posts: 69
"http-localhost-8080-70" daemon prio=10 tid=0x00002aaba8a28800 nid=0x611d in Object.wait() [0x0000000046275000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00002aab1e6a9708> (a org.apache.tomcat.util.net.JIoEndpoint$Worker)
at java.lang.Object.wait(Object.java:485)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.await(JIoEndpoint.java:416)
- locked <0x00002aab1e6a9708> (a org.apache.tomcat.util.net.JIoEndpoint$Worker)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:442)
at java.lang.Thread.run(Thread.java:619)


I am investigating slow performance of my app. 65% of the threads are in this state (WAITING).
I cant understand what the locked and waiting lines mean. Please explain.

Pappu
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21



When a thread executes line 02. it will show up as -locked <instance address> (type).
When a thread executes line 04. it will show up as - waiting on <instance address> (type).

You can also get 'locked' if you use a synchronized method in an instance of the JIoEndpoint.Worker class. The problem is that you have a lot of threads wait()ing and maybe not enough notify()s happening.


Steve
Pappu Kumar
Ranch Hand

Joined: Oct 01, 2002
Posts: 69
Steve,

Thanks for the prompt response. Another problem is that i don't know what needs to happen for the notify to take place.
Clearly the thread is busy doing something.

Can you recommend something in order to get much more detailed info ? For ex : I would like to what business methods in my app are waiting and which ones are slow to notify.

Hope i make sense.
Pappu
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18843
    
  40

Steve Luke wrote:The problem is that you have a lot of threads wait()ing and maybe not enough notify()s happening.


Or maybe you have a lot of threads waiting because there is nothing to do. For example, an app server with little to do will have most of the worker threads waiting for work.

To figure out the issue, the number of waiting threads is not enough -- you need to also take stack traces to see what they are waiting for too.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Pappu Kumar
Ranch Hand

Joined: Oct 01, 2002
Posts: 69
Henry,

I downloaded TDA to analyze my thread dumps and this is what it said :

Overall Thread Count 322
Overall Monitor Count 209
Number of threads waiting for a monitor 0
Number of threads locking a monitor 184
Number of threads sleeping on a monitor 216
Number of deadlocks 0
Number of Monitors without locking threads 0

67% of all threads are sleeping on a monitor.
This might indicate they are waiting for some external resource (e.g. database) which is overloaded or not available or are just waiting to get to do something (idle threads). You should check the sleeping threads with a filter excluding all idle threads.

"Number of threads sleeping on a monitor 216" - Doesn't this mean that they are waiting for a notify ?

I am going to try and get the stack trace and see what i can find.

Pappu
Pappu Kumar
Ranch Hand

Joined: Oct 01, 2002
Posts: 69
Guys,

Quick question. I am running Jboss. I got the thread dump using "/jstack pid" command but the dump file don't show any application classes that are being invoked.
The file contains Threads like i showed in my first post.

How do i get a stack trace that shows my application classes as well ?

Pappu
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18843
    
  40

You can trigger the JVM to dump the stack traces for all threads -- via a kill -QUIT for unix, and a control break for windows.

Henry
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Papppu,

What is TDA?


Groovy
Pappu Kumar
Ranch Hand

Joined: Oct 01, 2002
Posts: 69
https://tda.dev.java.net/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: New to threading. Help me analyze this excerpt from the dump