自带的分析工具就可以,比如 jstack,我找了一个博客上教程的输出结果:
```
Found one Java-level deadlock:
=============================
"Thread-1":
waiting to lock Monitor@0x00007fea1900f6b8 (Object@0x00000007efa684c8, a java/lang/Object),
which is held by "Thread-0"
"Thread-0":
waiting to lock Monitor@0x00007fea1900ceb0 (Object@0x00000007efa684d8, a java/lang/Object),
which is held by "Thread-1"
作者:江溢 Jonny
链接:
https://juejin.im/post/5aaf6ee76fb9a028d3753534来源:掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
就可以看出来 lock 对象是谁,这里的例子就是两个对象,因为这里的例子是分别持有对方的锁,如果是同一个对象就是同一个锁了。