Search code examples
javanetbeansdeadlock

How to find Deadlock using NetBeans?


I have a rare issue when my Java application freezes. Now I was able to reproduce it in debug mode in NetBeans. So it currently stays frozen, but I don't know how to find where exactly in the code it has the deadlock, and in which threads. The callstack window is empty, the threads screenshot is attached. What should I do to find the problem in the code?

enter image description here


Solution

  • In order to locate the deadlock you have to take a few consecutive thread dumps. And when you compare them you will see where the treads are waiting - this is your dead lock.

    You can use jstack (which should be part of your JDK installation) to take thread dumps or alternatively if you use Linux you can use kill -3 PID