📄 storage.java
字号:
public class Storage
{
private int count;
private int size;
public Storage(int s)
{
size = s;
}
public synchronized void addData(String n)
{
while (count == size)
{
try {
this.wait();
}
catch (InterruptedException e) { }
}
this.notify();
count++;
System.out.println(n+" make data count: "+count);
}
public synchronized void delData(String n)
{
while (count == 0)
{
try {
this.wait();
}
catch (InterruptedException e) { }
}
this.notify();
System.out.println(n+" use data count: "+count);
count--;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -