Java thread dump: WAITING (on object monitor) - what is it waiting on?

自闭症网瘾萝莉.ら 提交于 2019-12-03 07:04:17
apangin

It's a peculiarity of HotSpot JVM. When dumping a stack, JVM recovers the wait object from the method local variables. This info is available for interpreted methods, but not for compiled native wrappers.

When Object.wait is executed frequently enough, it gets JIT-compiled.
After that there will be no "waiting on" line in a thread dump.

  1. Since wait() must be called on a synchronized object, most often the wait object is the last locked object in the stack trace. In your case it is

    - locked <0x00007f98cbebe5d8> (a com.tibco.tibjms.TibjmsxResponse)
    
  2. To prevent Object.wait from being JIT-compiled (and thus making wait info always available) use the following JVM option

    -XX:CompileCommand="exclude,java/lang/Object.wait" 
    

This thread is waiting the notification from another thread (thread name is TCPLinkReader, if you look over the full thread dump you should be able to find it) which is created by the TIBCO EMS client library.

The stacktrace shows that the Spring application is trying to commit a session. To commit the session EMS client needs to send some data to server and waiting for the confirmation from server that the session is committed successfully or not.

TCPLinkReader thread is a dedicated thread that EMS client use to receive downstream (from server to client) TCP packets.

If you are seeing this thread lasts for long, there are 2 scenarios:

  • Something wrong on the EMS server side, possibly hung

  • there are some defects in the client library that caused deadlock, so server did send the response back but the TCPLinkReader thread did not notify the caller thread.

Last, post the full thread dump if problem persists.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!