Concurrent collections

With the introduction of concurrency api, the concurrent collections were also introduced.

Previously, we had to synchronize the collection object that we are using and at a time, single thread can only access that object.

And whenever we do not synchronize and multiple threads perform the operation on the same collection object, we are faced with concurrentmodificationexception.

But with these new utilities, multiple threads can perform operations at the same time.

Also the performance of the concurrent collections is faster since they use a new type of locking i.e. segment/block locking rather than locking the entire objects. This also makes them suitable for multithreaded, high performance, scalable applications.

Following are the concurrent collections :

ArrayBlockingQueue
ConcurrentHashMap
ConcurrentLinkedDeque
ConcurrentLinkedQueue
ConcurrentSkipListMap
ConcurrentSkipListSet
CopyOnWriteArrayList
CopyOnWriteArraySet
DelayQueue
LinkedBlockingDeque
LinkedBlockingQueue
LinkedTransferQueue
PriorityBlockingQueue
SynchronousQueue

They offer alternatives to the respective classes related to them in the collections framework.


Comments

Popular posts from this blog

Collection Framework - HashSet And LinkedHashSet class

Collection Framework - Cursors in Java

Hashed data structures