class SyncStack {
private int index = 0;
private int [] buffer = new int[6]; // 스택의 크기는 6개// 스택으로부터 꺼냄
public synchronized int pop() { //
while (index == 0) { // 하나도 없으면 기다림.
try {
this.wait();
} catch (InterruptedException e) { }
}
this.notify(); // 아니면, 수행
index--;