Deadlock detection in Java

后端 未结 16 1051
野的像风
野的像风 2020-11-28 20:21

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

16条回答
  •  孤城傲影
    2020-11-28 21:00

    Java 1.8 onwards, you can easily find if your program has a deadlock by using jcmd command on your terminal.

    1. Run jcmd on your terminal: It lists all the programs (PID and name) which are using Java.
    2. Now, run 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 help

提交回复
热议问题