请问有人能解释为什么这段代码是死锁。它似乎应该正常工作。请详细解释它。谢谢。Java中的多线程死锁
public class H extends Thread {
String info = "";
public H (String info) {
this.info = info;
}
public synchronized void run() {
try {
while (true) {
System.out.println(info);
notify();
wait();
}
} catch (Exception e) {}
}
public static void main(String[] args) {
new H("0").start();
new H("1").start();
}
}
它究竟是如何死锁?它打印两个东西,但没有终止? –
它打印而这就是卡在死锁 –