public static class Stack {
private final LinkedList<Integer> queue = new LinkedList<>();
public synchronized Integer pop() throws InterruptedException {
if (queue.size() <= 0) {
wait();
}
return queue.removeLast();
}
public synchronized void push(Integer integer) {
queue.addFirst(integer);
notify();
}
}
面试题..题目说这个栈在多线程中可能出现问题,请指出出现问题的情景...我想了半天也没想出来什么情景下回出问题,还请指教..
谢谢