Implementation of a bounded queue in Java