Code example for ArrayBlockingQueue

Methods: add, poll, size

0
	/** 
	 * adds new element in storage. if a new item is added when the maximum number is reached, then the oldest element is removed 
	 * @param element 
	 */ 
	public synchronized void add(E element){
		if(queue.size() == capacity){
			queue.poll();
		} 
		queue.add(element);
	} 
	 
	/** 
	 *  Returns an array containing all of the elements in this storage 
	 * @param array 
	 * @return 
	 */ 
	public synchronized E[] toArray(E[] array){ 
		return queue.toArray(array);
	}  
	 
}