I have a Java Thread Dump which clearly says I have a deadlock in my application:
"pool-2-thread-1":
waiting to lock monitor 0x00007f17b0040120 (object 0x00000000f731a9e0, a com.MyClass),
which is held by "pool-6-thread-1"
"pool-6-thread-1":
waiting to lock monitor 0x00007f17b803cfc0 (object 0x00000000f72e7e90, a com.MyOtherClass),
which is held by "pool-2-thread-1"
Now I want to understand which particular objects are locks, these two threads a waiting for. I have class names, but there are many instances of this type in my application. I want to understand which particular instance is causing this issue. The ideal way for would be to print toString() for that instance.
So the questions are:
0x00007f17b803cfc0
is the address at which the object is located in memory. You can make a heap dump and then find this object using a dump analyzer.
To make a dump you can use the jmap
command, to find an object at an address you can use VisualVM.
Here is an example of getting a dump.
jmap -dump:live,format=b,file=heapdump.hprof <PID>