📄 testdeadlock.java
字号:
public class TestDeadLock{
public static void main(String args[]){
StringBuffer sb = new StringBuffer("ABCD");
MyThread t = new MyThread(sb);
t.start();
synchronized(sb){
try{
t.join();
}catch(InterruptedException e){
e.printStackTrace();
}
System.out.println(sb);
}
System.out.println("Main thread is over!");
}
}
class MyThread extends Thread{
private StringBuffer sb;
public MyThread(StringBuffer sb){
this.sb = sb;
}
public void run(){
synchronized(sb){
sb.reverse();
}
System.out.println("Sub thread is over!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -