Skip to main content

javathreads and CPU utilization

3 replies [Last post]
kliu
Offline
Joined: 2007-05-30

Hello all,

I have a multi-threaded application that is taking a lot of CPU cycles. Tools like top and prstat indicate that my java process is running at 90+ % of CPU. Using jstack I can see all of the running threads. Is there tools that can tell me which thread is taking the CPU?

Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dwormald
Offline
Joined: 2008-05-05

I think that you can use top -H to find the CPU usage per thread for linux.

After you've used that to find the hot thread, you can match up the TID with the native thread id in java. That should tell you where to look in your code.

peter__lawrey
Offline
Joined: 2005-11-01

You can use a profiler.
There is a built in profiler called hprof but there is a number of free ones and commercial ones which will help you.

kliu
Offline
Joined: 2007-05-30

Thanks. Using hprof helped find the problem.