@Override
    public Integer get() {
        lock.lock();

        try {
            while (isEmpty()) {
                notEmpty.await();
            }

            // take item
            Integer item = buffer[oldest];
            buffer[oldest] = null;
            oldest = (1 + oldest) % buffer.length;

            notFull.signalAll();

            return item;
        } catch (InterruptedException ex) {
            System.out.println(Thread.currentThread() + "interrupted when getting item");
            return null;
        } finally {
            lock.unlock();
        }
    }