Pages

Friday, December 18, 2015

Learn java util concurrent part5

This is the last series of learning into java util concurrent package. If you have not read the series before, you can find part1, part2, part3 and part4 at the respectively links. In this series, we will study remaining 19 classes in java.util.concurrent package.

If you have a long running task, you can use FutureTask so the task can be cancel. Next, we will go into another three queues.

LinkedBlockingDeque<E>

An optionally-bounded blocking deque based on linked nodes.

The capacity, if unspecified, is equal to Integer.MAX_VALUE.

Most operations run in constant time (ignoring time spent blocking). Exceptions include remove, removeFirstOccurrence, removeLastOccurrence, contains, iterator.remove(), and the bulk operations, all of which run in linear time.

LinkedBlockingQueue<E>

An optionally-bounded blocking queue based on linked nodes.

This queue orders elements FIFO (first-in-first-out).

The head of the queue is that element that has been on the queue the longest time.

The tail of the queue is that element that has been on the queue the shortest time.

New elements are inserted at the tail of the queue, and the queue retrieval operations obtain elements at the head of the queue.

The capacity, if unspecified, is equal to Integer.MAX_VALUE.

LinkedTransferQueue<E>

An unbounded TransferQueue based on linked nodes.

This queue orders elements FIFO (first-in-first-out) with respect to any given producer.

The head of the queue is that element that has been on the queue the longest time for some producer.