📄 syncstack.txt
字号:
//SyncStack.java
//package modl3;
public class SyncStack
{ private int index=0;
private char buffer[]=new char[6];
public synchronized void push(char c)
{while(index==buffer.length)
{try{this.wait();}
catch(InterruptedException e){}
}
this.notify();
buffer[index]=c;
index++;
}
public synchronized char pop()
{while(index==0)
{try{this.wait();}
catch(InterruptedException e){}
}
this.notify();
index--;
return buffer[index];
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -