J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | FullThreadDump demonstrates the use of the java.lang.management API |
| 2 | to print the full thread dump. JDK 6 defines a new API to dump |
| 3 | the information about monitors and java.util.concurrent ownable |
| 4 | synchronizers. |
| 5 | |
| 6 | This demo also illustrates how to monitor JDK 5 and JDK 6 VMs with |
| 7 | two versions of APIs. |
| 8 | |
| 9 | It contains two parts: |
| 10 | a) Local monitoring within the application |
| 11 | b) Remote monitoring by connecting to a JMX agent with a JMX service URL: |
| 12 | service:jmx:rmi:///jndi/rmi://<hostName>:<portNum>/jmxrmi |
| 13 | where <hostName> is the hostname and <portNum> is the port number |
| 14 | to which the JMX agent will be connected. |
| 15 | |
| 16 | To run the demo |
| 17 | --------------- |
| 18 | a) Local Monitoring |
| 19 | |
| 20 | java -cp <JDK_HOME>/demo/management/FullThreadDump/FullThreadDump.jar Deadlock |
| 21 | |
| 22 | This will dump the stack trace and then detect deadlocks locally |
| 23 | within the application. |
| 24 | |
| 25 | b) Remote Monitoring |
| 26 | |
| 27 | (1) Start the Deadlock application (or any other application) |
| 28 | with the JMX agent as follows: |
| 29 | |
| 30 | java -Dcom.sun.management.jmxremote.port=1090 |
| 31 | -Dcom.sun.management.jmxremote.ssl=false |
| 32 | -Dcom.sun.management.jmxremote.authenticate=false |
| 33 | -cp <JDK_HOME>/demo/management/FullThreadDump/FullThreadDump.jar |
| 34 | Deadlock |
| 35 | |
| 36 | This instruction uses the Sun's built-in support to enable a JMX agent. |
| 37 | You can programmatically start a JMX agent with the RMI connector |
| 38 | using javax.management.remote API. See the javadoc and examples for |
| 39 | javax.management.remote API for details. |
| 40 | |
| 41 | (2) Run FullThreadDump |
| 42 | |
| 43 | java -jar <JDK_HOME>/demo/management/FullThreadDump/FullThreadDump.jar \ |
| 44 | localhost:1090 |
| 45 | |
| 46 | This will dump the stack trace and then print out the deadlocked threads. |
| 47 | |
| 48 | These instructions assume that this installation's version of the java |
| 49 | command is in your path. If it isn't, then you should either |
| 50 | specify the complete path to the java command or update your |
| 51 | PATH environment variable as described in the installation |
| 52 | instructions for the Java(TM) SDK. |