Java Reference
In-Depth Information
org.java8recipes.chapter11.recipe11_06.Recipe11_6.main(Recipe11_6.java:18)
Found 1 deadlock.
For this recipe to function properly on Windows, you must have as part of your
PATH
environment variable the JDK's bin folder (For example
C:\Program
Files\java\jdk1.8.0\bin
). If you have this path, you can run the tools such as
JStack and JPS. JStack comes pre-installed on OS X, so you should be able to run it out
of the box.
The JStack command uses as an argument
-l
(a dash and the letter
L
), which spe-
cifies a
Long
listing (it does extra work to get more information about the threads run-
ning). The JStack also needs to know the PID of the target VM. A quick way to list all
running JVMs is to type
JPS
and press Enter. This will list the running VMs and their
PIDs.
Figure 11-3
shows a screenshot of a JStack finding a deadlock in Recipe 11-6
from an OS X machine.
Figure 11-3
.
JStack results
Note
For the purposes of this example,
j.u.c.l
represents
java.util.concurrent.locks
, and
aqs
represents
AbstractQueuedSyn-
chronizer
.