Long time ago, I saved a sentence from a Java reference book: \"Java has no mechanism to handle deadlock. it won\'t even know deadlock occurred.\" (Head First Java 2nd E
Java 1.8 onwards, you can easily find if your program has a deadlock by using jcmd
command on your terminal.
jcmd
on your terminal: It lists all the programs (PID and name) which are using Java.jcmd Thread.print
: This will print the thread dump on your console and will also print if your program has a deadlock.You can analyse your Java program with more jcmd
options listed by command jcmd