- jdk自帶命令列工具:jsp + jstack -l pid
- jdk自帶視覺化工具:jvisualvm
- jdk自帶視覺化工具:jconsole
public class T {
public static void main(String[] args) throws InterruptedException {
Object lock1 = new Object();
Object lock2 = new Object();
new Thread(() -> {
try {
synchronized (lock1) {
Thread.sleep(200);
synchronized (lock2) {
}
}
} catch (Exception e) {
}
}, "執行緒1").start();
new Thread(() -> {
try {
synchronized (lock2) {
Thread.sleep(200);
synchronized (lock1) {
}
}
} catch (Exception e) {
}
}, "執行緒2").start();
}
}