It is also called Concurrent Collections. Most of the popular collection classes have implementations for both single thread and multiple thread environments. The non-syncronized implementations are always faster. You can use the non-syncronized implementations in multiple thread environments, when you make sure that only one thread updating the collection an any given time.
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.
The following table list all the syncronized collection classes
syncronized | non-syncronized | |
---|---|---|
List | java.util.Vector | java.util.ArrayList |
java.util.Stack | ||
java.util.LinkList | ||
java.util.concurrent.CopyOnWriteArrayList | ||
Set | java.util.TreeSet | |
java.util.HashSet | ||
java.util.LinkHashSet | ||
java.util.concurrent.CopyOnWriteArraySet | ||
Map | java.util.TreeMap | |
java.util.Hashtable java.util.concurrent.ConcurrentHashMap | java.util.HashMap | |
java.util.LinkHashMap | ||
java.util.IdentityHashMap | ||
java.util.EnumMap |
沒有留言:
張貼留言