Joehot200
Joehot200

Reputation: 49

How/Where to find where a thread has been locked?

I have got an issue where a crucial thread in my game is becoming locked for no discoverable reason.

How can I find the line of code that is trying to execute at the time that the thread has been locked?

I am using the Eclipse IDE.

Thanks!

Upvotes: 1

Views: 60

Answers (2)

Thomas Uhrig
Thomas Uhrig

Reputation: 31605

You could use the Eclipse debugger for it. Don't run you app via the normal run button, but with the debug button right besides of it.

enter image description here

Play your game and create the situation that will end in the deadlock. Then you can go to Eclipse and switch to the debug perspective. You will see all running threads and the methods executed (the complete stack to be precise).

enter image description here

Upvotes: 3

cherouvim
cherouvim

Reputation: 31903

When the app is blocked you need to do a thread dump. From the console it should be something like :

jstack <pid>

or:

kill -3 <pid>

where <pid> is the process id of the jvm running your application.

That will tell you where exactly the thread is blocked together with the stacktrace which lead to the execution of that piece of code.

Upvotes: 0

Related Questions