- Array: The Array class is a strongly typed base class for language implementations that support arrays.
- ArrayList: The size is of a ArrayList is dynamically increased as required. An ArrayList can support multiple readers concurrently, as long as the collection is not modified. To guarantee the thread safety of the ArrayList, all operations must be done through the wrapper returned by the Synchronized method.
- BitArray: It manages a compact array of bit values, which are represented as Booleans. This implementation does not provide a synchronized (thread safe) wrapper for a BitArray.
- HashTable: Represents a collection of key/value pairs that are organized based on the hash code of the key. Hashtable is thread safe for use by multiple reader threads and a single writing thread. To support multiple writers all operations on the Hashtable must be done through the wrapper returned by the Synchronized method, provided that there are no threads reading the Hashtable object.
- ListDictionary: It is as singly linked list and is recommended for collections that typically contain 10 items or less. This implementation does not provide a synchronized (thread safe) wrapper for a ListDictionary.
- HybridDictionary: Uses a ListDictionary while the collection is small, and then switches to a Hashtable when the collection gets large.This implementation does not provide a synchronized (thread safe) wrapper for a HybridDictionary.
- OrderedDictionary: Represents a collection of key/value pairs that are not sorted in any way and are accessible by the key or index.
- SortedList: Represents a collection of key/value pairs that are sorted by the keys and are accessible by key and by index. A SortedList object can support multiple readers concurrently, as long as the collection is not modified. To guarantee the thread safety of the SortedList, all operations must be done through the wrapper returned by the Synchronized method.
- Queue: Represents a first-in, first-out collection of objects. To guarantee the thread safety of the Queue, all operations must be done through the wrapper returned by the Synchronized method.
- Stack: Represents a simple last-in-first-out (LIFO) non-generic collection of objects. To guarantee the thread safety of the Stack, all operations must be done through the wrapper returned by the Synchronized method.
General: Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.
No comments:
Post a Comment