Thread-Safe Collections
Home ] Up ] What is MultiThreading? ] Threads & Thread Properties ] Thread Scheduling and Priority ] Types of Threads ] Monitors, Synchronization and Deadlocks ] Thread Coordination ] Communication Between Threads ] Threads and Thread Groups ] Explicit Locks ] Atomic Variables ] Blocking Queues ] [ Thread-Safe Collections ] Callables & Futures ] The Executor Framework ] Synchronizers ]

 

 

In addition to the BlockingQueue interface, Java 5 also added new collection classes (concurrent collections), including the Queue interface, as well as high-performance concurrent implementations of Map, List, and Queue.

Specifically:

  • ConcurrentMap interface -- A Map providing additional atomic putIfAbsent, remove, and replace methods.
  • ConcurrentNavigableMap interface -- A ConcurrentMap supporting NavigableMap operations, and recursively so for its navigable sub-maps.
  • ConcurrentHashMap -- A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updates.
  • ConcurrentLinkedQueue -- An unbounded thread-safe queue based on linked nodes.
  • ConcurrentSkipListMap -- A scalable concurrent ConcurrentNavigableMap implementation.
  • ConcurrentSkipListSet -- A scalable concurrent NavigableSet implementation based on a ConcurrentSkipListMap.

Also, there are copy-on-write thread-safe collections:

  • CopyOnWriteArrayList --  A thread-safe variant of ArrayList in which all mutative operations (add, set, and so on) are implemented by making a fresh copy of the underlying array.
  • CopyOnWriteArraySet -- A Set that uses an internal CopyOnWriteArrayList for all of its operations.
 
The page was last updated February 19, 2008