Java Concurrency - (Concurrent) Collections

About

All of the concurrent collections help avoid Memory Consistency Errors by defining a happens-before relationship between:

  • an operation that adds an object to the collection
  • with subsequent operations that access or remove that object.

List

The java.util.concurrent package includes a number of additions to the Java Collections Framework.

  • ConcurrentMap is a subinterface of java.util.Map that defines useful atomic operations. These operations remove or replace a key-value pair only if the key is present, or add a key-value pair only if the key is absent. Making these operations atomic helps avoid synchronization. The standard general-purpose implementation of ConcurrentMap is ConcurrentHashMap, which is a concurrent analog of HashMap.
  • ConcurrentNavigableMap is a subinterface of ConcurrentMap that supports approximate matches. The standard general-purpose implementation of ConcurrentNavigableMap is ConcurrentSkipListMap, which is a concurrent analog of TreeMap.

Documentation / Reference


Powered by ComboStrap