Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I profile threads in Java?

I have producer and consumer threads in my application and I need to profile them to see the performance of the threads, time taken before each goes to sleep and waits, etc., and take corrective action to improve the over all efficiency of the application.

Any suggestions on how to go about this?

like image 473
sashank Avatar asked Feb 23 '11 04:02

sashank


People also ask

How do you code profiling in Java?

We can use profilers for this. A Java Profiler is a tool that monitors Java bytecode constructs and operations at the JVM level. These code constructs and operations include object creation, iterative executions (including recursive calls), method executions, thread executions, and garbage collections.

What is a thread profiler?

The thread profiler is a low-impact profiling tool that can be used in production to identify bottlenecks in an application. It works by periodically (100ms) capturing the stack trace of each thread for a specified duration. At the end of the specified duration, the stack traces are aggregated to build a tree.

How do you manage threads in Java?

Every Java program contains at least one thread: the main thread. Additional threads are created through the Thread constructor or by instantiating classes that extend the Thread class. Java threads can create other threads by instantiating a Thread object directly or an object that extends Thread .


1 Answers

Personally I use YourKit java profiler. It has an excellent thread profiler tool that graphically shows the state of each thread at any given time, relative to one another (among other things). Worth a look

http://www.yourkit.com/overview/index.jsp

like image 104
Renan Avatar answered Oct 22 '22 06:10

Renan