Java Reference
In-Depth Information
Java SE 7:
Java SE 8
Collection
Description
ArrayBlockingQueue
A fixed-size queue that supports the producer/consumer relationship—
possibly with many producers and consumers.
ConcurrentHashMap
A hash-based map (similar to the
HashMap
introduced in Chapter 16)
that allows an arbitrary number of reader threads and a limited num-
ber of writer threads. This and the
LinkedBlockingQueue
are by far the
most frequently used concurrent collections.
ConcurrentLinkedDeque
A concurrent linked-list implementation of a double-ended queue.
ConcurrentLinkedQueue
A concurrent linked-list implementation of a queue that can grow
dynamically.
ConcurrentSkipListMap
A concurrent map that is sorted by its keys.
ConcurrentSkipListSet
A sorted concurrent set.
CopyOnWriteArrayList
A thread-safe
ArrayList
. Each operation that modifies the collection
first creates a new copy of the contents. Used when the collection is tra-
versed much more frequently than the collection's contents are modified.
CopyOnWriteArraySet
A set that's implemented using
CopyOnWriteArrayList
.
DelayQueue
A variable-size queue containing
Delayed
objects. An object can be
removed only after its delay has expired.
LinkedBlockingDeque
A double-ended blocking queue implemented as a linked list that can
optionally be fixed in size.
LinkedBlockingQueue
A blocking queue implemented as a linked list that can optionally be
fixed in size. This and the
ConcurrentHashMap
are by far the most fre-
quently used concurrent collections.
LinkedTransferQueue
A linked-list implementation of interface
TransferQueue
. Each producer
has the option of waiting for a consumer to take an element being
inserted (via method
transfer
) or simply placing the element into the
queue (via method put). Also provides overloaded method
tryTransfer
to immediately transfer an element to a waiting consumer or to do so
within a specified timeout period. If the transfer cannot be completed,
the element is not placed in the queue. Typically used in applications
that pass messages between threads.
PriorityBlockingQueue
A variable-length priority-based blocking queue (like a
PriorityQueue
).
SynchronousQueue
[For experts.] A blocking queue implementation that does not have an
internal capacity. Each insert operation by one thread must wait for a
remove operation from another thread and vice versa.
Fig. 23.22
|
Concurrent collections summary (package
java.util.concurrent
).