Code example for LinkedBlockingQueue

Methods: addremoveoffer

0
	/* (non-Javadoc) 
	 * @see java.util.HashMap#put(java.lang.Object, java.lang.Object) 
	 */ 
	@Override 
	public V put(K key, V value) {
		if (!queue.offer(key)) {
			remove(queue.remove());
			queue.add(key);
		} 
		return super.put(key, value);
	} 
 
	/** 
	 * Always throws UnsupportedOperationException 
	 * @throws UnsupportedOperationException 
	 */ 
	@Override 
	public void putAll(Map<? extends K, ? extends V> m) {
		throw new UnsupportedOperationException();
	}