Thread heap: Name your thread and view your system
Source: Internet
Author: User
Thread heap: Name your thread and view information about your system-general Linux technology-Linux programming and kernel. For more information, see the following. The Development Environment (IDE) provides a good debugging tool for graphic interface applications, but it cannot debug a multi-threaded Java server program.
Fortunately, there are several tools, such as the logging application interface (API) or Java Debugger, that can be used to debug Java server programs. Developers can also use the thread heap of a system to observe the status of the system at any time.
Run the server and press [ctrl] [/] to run a system thread heap, which will output all the currently running threads, 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 the others are related to the running server program. These two threads are named Thread-1 and Thread-0. If Thread th = new Thread (runnable, "Server") is used instead of Thread th = new Thread (runnable) to create a process, you can name the thread you want to create.
In addition, if you call java. lang. thread's setName (String) method, you can also name your Thread, and it is easy to find from the output of the Thread heap that the original Thread-0 is a server program.
"Server" prio = 5 tid = 0xafde0 nid = 0x72a00 runnable [0x173f000 .. 0x173fb48]
The original Thread-1 Thread is now Thread-0.
By naming the thread and getting the thread heap, the developer can see the internal status of the Java Virtual Machine (JVM. If you want more information, you have to study Java Debugger.
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.