编写最短的代码以创建死锁。代码执行必须停止,所以这不起作用:
public class DeadlockFail extends Thread{ //Java code
public static void main(String[]a){
Thread t = new DeadlockFail();
t.start();
t.join();
}
//this part is an infinite loop; continues running the loop.
public void run(){while(true){}}
}
Code execution must halt
我不明白 如果停止,它将如何陷入僵局?您是说它会等待某件事,而不只是像个混蛋那样自旋吗?