±Û¾´ÀÌ :±è±¤»ï 1999³â 9¿ù 02ÀÏ 16:54:03
In Reply to: ½ºÅà °ü·Ã Áú¹®ÀÌ¿ä.. posted by ±èÀº°æ on 1999³â 8¿ù 27ÀÏ 15:23:19:
±×³É Çпø´Ù´Ò¶§ ½É½ÉÇؼ ¸¸µé¾îº» ½ºÅÃŬ·¡½º¿¡¿ä~
µµ¿òÀÌ µÉÁö´Â ¸ð¸£°ÚÁö¸¸.
class KimStack {
char[] stack = new char[6];
char answer;
public int head;
public synchronized char pop() {
while(head==0) {
try {
wait();
} catch(InterruptedException e) { }
}
head--;
answer = stack[head];
notifyAll();
return answer;
}
public synchronized void push(char value) {
while (head==stack.length) {
try {
wait();
}catch(InterruptedException e) { }
}
stack[head] = value;
head++;
notifyAll();
}
}