queue The main principle is first in first out (excepted).
The difference between basic methods
(
Add data:
add Add a metarope and throw an IIIega ISlabEeplian exception if the queue is full
put Add an element if the queue is full, then block.
offer Add an element and return to true. If the queue is full, then return to false.
Remove data:
remove Remove and return the element at the head of the queue if the queue is empty, throw a NoSuchElementException exception
poll Removes and returns the elements of the queue header if the queue is empty, then returns null.
take Removing and returning elements of queue header
Returns header information:
peek If the queue is empty, the element returned to the queue header is returned to null.
element An element returning the head of the queue throws a NoSuchElementException if the queue is empty
)
javaThe queue is mainly used for multithreading.
PriorityQueue
PriorityQueueInstead of a standard queue implementation, PriorityQueue saves the queue elements not in the order they join the queue, but in the order they are reordered according to the size of the queue elements, which can be done from its class name
Deque
DequeThe interface represents a "double-ended queue" that adds and deletes elements from both ends at the same time, so Deque's implementation class can be used either as a queue or as a stack.
ConcurrentLinkedQueue
A lock free queue
BlockingQueue A blocked queue.
ArrayBlockingQueue Queue based on array needs to define length.
LinkedBlockingQueue A blocking efficient concurrent queue based on linked list, an unbounded queue;
PriorityBlockingQueue Priority based blocking queue
DelayQueue Blocking queue with delayed effect can not be removed without time.
SynchronousQueue Caching free queue
)