JDK 1.5 THREAD MONITOR Web Age Solutions Inc. INTRODUCTION This is a high performance thread monitor that can be used with a Java 1.5 VM. It has been tested with Sun JVM 1.5. The monitor shows a list of threads and their status. You can select a thread from the list to view a stack trace. The GUI runs in the same address space as the JVM. The monitor and the GUI is developed in C++ following the JVMTI API for maximum performance. The tool adds minimal performance overhead. You should be able to use it in a high load environment to debug thread deadlock or application hanging issues. DOWNLOAD AND INSTALLATION This tool requires Windows. It has been tested in Windows 2000 but should work in other variants as well. It needs Java 1.5. It has been tested with Sun JDK 22.214.171.124. Download the DLL file from here. Copy the DLL in any folder that is in your PATH. For example C:\WINNT. HOW TO USE THE TOOL? You can use this tool to monitor threads of any Java application. This includes J2EE applications running in an application server (Tomcat or JBoss for example). Only make sure that you are using Sun JDK 1.5 to run the application. Just add “-agentlib:tm” to the command line. For example: java -agentlib:tm com.webage.Test The GUI will open up immediately. The top half of the screen show the list of threads and their status. Select a thread to view the stack trace in the bottom half of the screen. Click on the Refresh button to refresh both lists. DETECTING PROBLEMS A deadlocked thread will be in “Waiting Indefinitely” status for a long time. Notice, “Waiting Indefinitely” itself is not a bad thing. It simply means that a thread is waiting for notification without a timeout. A thread is supposed to wake up when notification is received. The problem with a deadlocked thread is that the notification never arrives. If your application is hanging, look at the stack trace of the threads. In the above example, we look at the stack trace of the TP-Processor7 thread running in JBoss. These threads are used by the web container to run Servlets and JSPs. Focus on the first couple of methods of the stack trace. What is the thread doing? Why is it taking so long for the methods to complete? The file name and the line number will really help you narrow down the problem. DEFECTS There are no known defects at this point. This tool uses low level code and a defect can bring down the JVM. Test it thoroughly before deciding to use it in production. Please report any defect using the feedback form below. LICENSING AND SOURCE CODE You are free to use this tool in any circumstances. There is no warranty of any kind. Web Age is not responsible for any damage of loss caused by this tool. Source code for this tool can be downloaded here.