guava/src/com/google/common/collect/Queues.java
public static <E> Deque<E> synchronizedDeque(Deque<E> deque) {
    return Synchronized.deque(deque, null);
  }
public static <E> Deque<E> synchronizedDeque(Deque<E> deque) {
    return Synchronized.deque(deque, null);
  }
public static < E > Deque < E > synchronizedDeque ( Deque < E > deque ) { return Synchronized . deque ( deque , null ) ; }
Returns a synchronized (thread-safe) deque backed by the specified deque. In order to guarantee
serial access, it is critical that <b>all</b> access to the backing deque is accomplished
through the returned deque.

<p>It is imperative that the user manually synchronize on the returned deque when accessing any
of the deque's iterators:

<pre>{@code
Deque<E> deque = Queues.synchronizedDeque(Queues.<E>newArrayDeque());
...
deque.add(element);  // Needn't be in synchronized block
...
synchronized (deque) {  // Must synchronize on deque!
Iterator<E> i = deque.iterator(); // Must be in synchronized block
while (i.hasNext()) {
foo(i.next());
}
}
}</pre>

<p>Failure to follow this advice may result in non-deterministic behavior.

<p>The returned deque will be serializable if the specified deque is serializable.

@param deque the deque to be wrapped in a synchronized view
@return a synchronized view of the specified deque
@since 15.0
Returns a synchronized ( thread - safe ) deque backed by the specified deque . In order to guarantee serial access it is critical that <b > all< / b > access to the backing deque is accomplished through the returned deque .