Wednesday, May 12, 2010

Thread Safe Collections

A new Java JDK package was introduced at Java 1.5, that is java.util.concurrent. This package supplies a few Collection implementations designed for use in multithreaded environments.

You can use the non-synchronized implementations in multiple thread environments, when you make sure that only one thread updating the collection at any given time.

The following table list all the syncronized collection classes:


syncronized non-syncronized

Vector ArrayList
Stack

LinkList
CopyOnWriteArrayList


jTreeSet

HashSet

LinkHashSet
CopyOnWriteArraySet


TreeMap
Hashtable

ConcurrentHashMap

jHashMap

LinkHashMap

IdentityHashMap

EnumMap

No comments:

Post a Comment