Java threading and JVM monitoring tools

Source: Internet
Author: User

Java Thread State

Five states of a thread

* Newly created: New (time is short)

* Run: runnable

* Wait: waitting (wait indefinitely), timed waitting (Deadline wait)

* Blocking: Blocked

* End: Terminated (time is short)

JVM Monitoring Tools

First, Jstack

Introduced:

The jstack is used to print out the Java stack information for a given Java process ID or core file or remote Debugging service.
If you need to specify the option "-j-d64" on a 64-bit machine, the Jstack usage of Windows only supports this way: jstack [-l] PID
If a Java program crashes generating a core file, the Jstack tool can be used to obtain information about the core file's Java stack and the native stack, making it easy to know how the Java program crashes and where the problem occurs in the program.
In addition, the Jstack tool can be attached to a running Java program to see the Java stack and the native stack of the Java program that was running, and jstack is useful if the Java program that is running now renders hung state.

Use:

1. View the process number of the running program

2. Jstack Dump Current thread state

3, according to the information currently crawled to further analysis

Second, JVISUALVM

The JDK comes with a JVISUALVM tool, which is used to monitor the CPU, memory, thread, and so on of the Java Runtime program. and monitor Java programs in a graphical way with remote monitoring capabilities.

Pre-preparation

1, upload tomcat to the virtual machine, WebApps under the existence of Prefteach package

2, monitoring the JVM before the monitoring parameters, in the Tomcat bin directory, catalina.sh file, search java_opts=, in the IF, add:

-dcom.sun.management.jmxremote.port=10086-dcom.sun.management.jmxremote.ssl=false- Dcom.sun.management.jmxremote.authenticate=false-djava.rmi.server.hostname=192.168.1.101
The above additions need to be modified in two places:
1-Change port
2-change hostname to native IP

3. Start Tomcat and open the output log:./startup.sh. /logs/catalina.out

JVISUALVM use

1. Windows key +r key input JVISUALVM Enter

2. Right-click to add remote host remotely

3. Right-click on host IP to add JMV connection

4. Enter the port number of the remote connection click OK

5. Double-click 192.168.1.101:10086 to open the interface as shown

6, enter JVISUALVM always check the program running status

Note: It is possible in a test environment to have no permissions on the server to add a configuration that requires remote connections, so that only jstack

Java threading and JVM monitoring tools

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.