![]() |
VOOZH | about |
The LinkedBlockingDeque class introduced in JDK 1.6 is present in java.util.concurrent package. It is a deque which means a doubly ended queue. The default size of LinkedBlockingDeque is Integer.MAX_VALUE. It implements the BlockingDeque class and provides an optionally-bounded functionality based on linked nodes. This optional boundedness is served by passing the required size in the constructor and helps in preventing memory wastage. This class blocks a thread if that thread tries to remove elements out of an empty deque.
It implements Serializable, Iterable<E>, Collection<E>, BlockingDeque<E>, BlockingQueue<E>, Deque<E>, Queue<E> interfaces and extends AbstractQueue<E> and AbstractCollection<E> classes.
Declaration:
public class LinkedBlockingDeque<E> extends AbstractQueue<E> implements BlockingDeque<E>, Serializable
Here, E is the type of elements stored in the collection.
Implementation of LinkedBlockingDeque API :
the elements of the linkedBlockingDeque is 10 20 30 the peak element of the linkedBlockingDeque is(by peeking) 10 the peak element of the linkedBlockingDeque is(by polling) 10 the remaining capacity is 2147483643 element 30 removed true the linkedBlockingDeque contains 40 :false the linkedBlockingDeque contains 10 :false the size of the linkedBlockingDeque is 3 [20, 60, 70]