Analyzing Java programs with the Jstack tool

Source: Internet
Author: User

The recent project encountered a problem, my multiple collection threads, one thread is often suspended, the thread is not dead, but has not been collected data, in order to solve this problem, the use of jstack.

First find the Java process pid,ps-ef|grep Java

Then enter the Jstack PID

The core output is:

"Msg_receive_thread" prio=10 tid=0x00007fd95034b000 nid=0x2db5 runnable [0x00007fd9d0c26000] Java.lang.Thread.State:RUNNABLE at java.net.SocketInputStream.socketRead0 (Native Method) at Java.net.Socket Inputstream.read (Socketinputstream.java:152) at Java.net.SocketInputStream.read (Socketinputstream.java:122) at Com.ibm.mq.jmqi.remote.internal.RemoteTCPConnection.receive (Remotetcpconnection.java:1343) at Com.ibm.mq.jmqi.remote.internal.system.RemoteConnection.receiveTSH (Remoteconnection.java:2834) at Com.ibm.mq.jmqi.remote.internal.system.RemoteConnection.initSess (Remoteconnection.java:1428) at Com.ibm.mq.jmqi.remote.internal.system.RemoteConnection.connect (Remoteconnection.java:1106)    -Locked <0x00000000e7d97f18>(a Com.ibm.mq.jmqi.remote.internal.system.remoteconnection$connectionmutex) at Com.ibm.mq.jmqi.remote.internal.system.RemoteConnectionPool.getConnection (Remoteconnectionpool.java:349) at Com.ibm.mq.jmqi.remote.internal.RemoteFAP.jmqiConnect (Remotefap.java:1511) at Com.ibm.mq.MQSESSION.MQCONNX_j (Mqsession.java:915) at com.ibm.mq.MQManagedConnectionJ11.<init> (mqmanagedconnectionj11.java:226) at Com.ibm.mq.mqclientmanagedconnectionfactoryj11._createmanagedconnection ( Mqclientmanagedconnectionfactoryj11.java:505) at Com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection ( Mqclientmanagedconnectionfactoryj11.java:547) at com.ibm.mq.StoredManagedConnection.<init> (storedmanagedconnection.java:95) at Com.ibm.mq.MQSimpleConnectionManager.allocateConnection (Mqsimpleconnectionmanager.java:182) at Com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager (Mqqueuemanagerfactory.java:869) at Com.ibm.mq.MQQueueManagerFactory.procure (Mqqueuemanagerfactory.java:761) at Com.ibm.mq.MQQueueManagerFactory.constructQueueManager (Mqqueuemanagerfactory.java:712) at Com.ibm.mq.MQQueueManagerFactory.createQueueManager (Mqqueuemanagerfactory.java:171) at Com.ibm.mq.MQQueueManager.<init> (mqqueuemanager.java:603) at Com.wisdombud.unicom.monitor.listener.MessageByMQ.<init> (messagebymq.java:48) at com.wisdombud.unicom.monitor.listener.collectmain$14.run (collectmain.java:257) at Java.util.concurrent.executors$runnableadapter.call (Executors.java:471) at Java.util.concurrent.FutureTask.runAndReset (Futuretask.java:304) at java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.access$301 (scheduledthreadpoolexecutor.java:178) at Java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.run ( Scheduledthreadpoolexecutor.java:293) at Java.util.concurrent.ThreadPoolExecutor.runWorker (Threadpoolexecutor.java:1145) at Java.util.concurrent.threadpoolexecutor$worker.run (Threadpoolexecutor.java:615) at Java.lang.Thread.run (Thread.java:745)

As you can see, the thread is running, but hangs on the

java.net.SocketInputStream.socketRead0


through this sentence, you can find the cause of the problem, because one of IBM's products has a problem.

If you don't have a jstack, you don't know what to do with it.

basic usage of jstack:

command format:
jstack [option] PID
Basic parameters:
-F when ' jstack [-l] PID ' does not have a corresponding time to force the printing stack information
- L long list. Prints additional information about the lock, such as the ownable synchronizers list that belongs to Java.util.concurrent.
-M prints all of the stack information for Java and Native/C + + frameworks.
- H |-help printing help information
The PID requires the Java process ID of the configuration information to be printed and can be queried with JPS.

Specific usage
jstack-l Process ID


Also, for more information, please refer to:
Http://www.blogjava.net/jzone/articles/303979.html

Analyzing Java programs with the Jstack tool

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.