Thread dump: Name your thread and view system

Source: Internet
Author: User
Thread dump: Name your thread and view system-Linux general technology-Linux programming and kernel information. The following is a detailed description. Although the integrated development environment (IDE) can provide good debugging settings for graphical applications, it does not allow you to debug multi-threaded Java server programs.


Fortunately, there are several tools that can be done, such as the log application interface (API) and Java debugger. Developers can also obtain the system thread dump, which can display the system status at any time.

To get the system thread dump, run the server program and type [Ctrl] [\]. This will output all the threads that are being executed. For example:

^ \ Full thread dump:

Thread-1 "prio = 5 tid = 0x87fe0 nid = 0x800013b8 waiting on monitor [0 .. 0xbfffe9f8]

"Thread-0" prio = 5 tid = 0xafde0 nid = 0x72a00 runnable [0x173f000 .. 0x173fb48]
At java.net. PlainSocketImpl. socketAccept (Native Method)
At java.net. PlainSocketImpl. accept (PlainSocketImpl. java: 421)
At java.net. ServerSocket. implAccept (ServerSocket. java: 243)
At java.net. ServerSocket. accept (ServerSocket. java: 222)
At com.generationjava.net. PortListener. run (PortListener. java: 38)
At java. lang. Thread. run (Thread. java: 496)

"Signal Dispatcher" daemon prio = 10 tid = 0xa5f80 nid = 0x52af0 waiting on monitor [0 .. 0]

"Finalizer" daemon prio = 8 tid = 0xa46c0 nid = 0x4d930 waiting on monitor [0x10a8000 .. 0x10a8b48]
At java. lang. Object. wait (Native Method)
At java. lang. ref. ReferenceQueue. remove (ReferenceQueue. java: 108)
At java. lang. ref. ReferenceQueue. remove (ReferenceQueue. java: 123)
At java. lang. ref. Finalizer $ FinalizerThread. run (Finalizer. java: 162)

"Reference Handler" daemon prio = 10 tid = 0xa3b70 nid = 0x4cca0 waiting on monitor [0x1027000 .. 0x1027b48]
At java. lang. Object. wait (Native Method)
At java. lang. Object. wait (Object. java: 420)
At java. lang. ref. Reference $ ReferenceHandler. run (Reference. java: 110)

"VM Thread" prio = 5 tid = 0xa2de0 nid = 0x4ca20 runnable

"VM Periodic Task Thread" prio = 10 tid = 0xa56b0 nid = 0x52890 waiting on monitor

The following four threads are standard threads, while others are related to specific running server programs. These two threads are named Thread-1 and Thread-0. Change the names of these threads and call them at creation:

Thread th = new Thread (runnable, "Server ");
The alternative is as follows:

Thread th = new Thread (runnable );
In addition, if you call the setName (String) method of java. lang. Thread, you can name your Thread and notice in the output that Thread-0 is the server program.

"Server" prio = 5 tid = 0xafde0 nid = 0x72a00 runnable [0x173f000 .. 0x173fb48]
The previous Thread-1 Thread is now named Thread-0.

By naming threads and getting thread dump, developers can view the state of a Java Virtual Machine (JVM. To go further, developers must explore the Java debugger.
Related Article

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.