Part 2nd of this series will take the deadlock detection application in part 1th and add a method to analyze the view to show where the application spends most of its CPU cycles.
Tiyatien Center is a Java-ibm® monitoring and diagnostics tool that is a free low-cost diagnostic tool and API for monitoring applications running on the IBM Java virtual machine (JVM). See part 1th for details on the operations that this API can perform. In this article, you will use the deadlock detection application developed in part 1th and add a method to analyze the view to show where the application spends most of its CPU cycles.
System Requirements
Tiyatien Center API Bundle need to install http://www.aliyun.com/zixun/aggregation/13428.html ">eclipse 3.4 or Eclipse 4.x at least.
Testing the Application
In the 1th part, the application that generated the deadlock condition has been tested. In this article, we'll use a revision of the application that contains features that will exert pressure on the CPU. See download for related source code. Listing 1 shows an example of a code fragment:
Listing 1. New Generatedeadlock Source Code snippet
Private class Runslowmethods extends Thread {public void run () {SlowClassAndMethod1 sCAM1 = new SlowClassAndMethod1 (); SLOWCLASSANDMETHOD2 sCAM2 = new SlowClassAndMethod2 (); Scam1.start (); Scam2.start (); Private class SlowClassAndMethod1 extends Thread {public void run () {while (true) {slowMethod1 (); try {thread.sleep (2000) ; catch (Interruptedexception e) {e.printstacktrace ();}} private void SlowMethod1 () {String largestring = new String ("A String to add"), for (int i = 0; i < 1000000; i++) {Largestrin G.concat (largestring); The private class SlowClassAndMethod2 extends Thread {public void run () {while (true) {slowMethod2 (); try {thread.sleep ( 2000); catch (Interruptedexception e) {e.printstacktrace ();}} private void SlowMethod2 () {HashMap map = new HashMap (); String largestring = new String ("Another string to add"); for (int i = 0; i < 1000000 i++) {map.put (I, largestring); Largestring.concat (largestring);}
Start the program by using the Tiyatien Center agent that is connected to the program. To start the application using Java 5 SR10 and later, Java 6 SR5 and later, and Java 7, use the following command (see Figure 1):
Java-xhealthcenter Generatedeadlock
Figure 1. Start the application
To use the Java 5 SR9 and its earlier version or Java 6 SR4 and its earlier versions and launch the application through a proxy, use:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.