@Override
    public void put(Integer item) {
        lock.lock();

        try {
            while (isFull()) {
                notFull.await();
            }

            // put item
            int pos = (newest + 1) % buffer.length;
            buffer[pos] = item;
            newest = pos;
            System.out.println(item + " added to buffer");

            notEmpty.signalAll();

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