CMPE 261 - Lab worksheet - Week 10

Problem 1: Unsafe buffer implementation

A buffer is a limited amount of ordered storage, common in many applications. It has a certain capacity, and one can push and pop values from it, as a queue. Thus an interace as follows can be used to represent a buffer:

    interface Buffer<T> {
        boolean isEmpty();
        boolean isFull();
        int totalCapacity();
        void push(T) throws Exception;
        T pop() throws Exception;

Write a generic typed class to implement a buffer of given type.

Problem 1: Safe buffer implementation

Modify your class to obtain a buffer object which is safe against concurrent modifications.