@Override
    public synchronized Integer get() {
        while (isEmpty()) {
            try {
                wait();
            } catch (InterruptedException ex) {
                System.out.println("Interrupted exception in thread "
                + Thread.currentThread() + " while getting an item");
                return null;
            }
        }
        
        // here the buffer is not empty, get oldest item
        Integer item = buffer[oldest];
        buffer[oldest] = null;
        oldest = (1 + oldest) % buffer.length;
        
        notifyAll();
        
        return item;
    }