| java.lang.Object org.apache.commons.collections.collection.SynchronizedCollection
All known Subclasses: org.apache.commons.collections.list.SynchronizedList, org.apache.commons.collections.buffer.SynchronizedBuffer, org.apache.commons.collections.bag.SynchronizedBag, org.apache.commons.collections.set.SynchronizedSet, org.apache.commons.collections.set.SynchronizedSortedSet,
SynchronizedCollection | public class SynchronizedCollection implements Collection,Serializable(Code) | | Decorates another Collection to synchronize its behaviour
for a multi-threaded environment.
Iterators must be manually synchronized:
synchronized (coll) {
Iterator it = coll.iterator();
// do stuff with iterator
}
This class is Serializable from Commons Collections 3.1.
since: Commons Collections 3.0 version: $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $ author: Stephen Colebourne |
collection | final protected Collection collection(Code) | | The collection to decorate
|
lock | final protected Object lock(Code) | | The object to lock on, needed for List/SortedSet views
|
SynchronizedCollection | protected SynchronizedCollection(Collection collection)(Code) | | Constructor that wraps (not copies).
Parameters: collection - the collection to decorate, must not be null throws: IllegalArgumentException - if the collection is null |
SynchronizedCollection | protected SynchronizedCollection(Collection collection, Object lock)(Code) | | Constructor that wraps (not copies).
Parameters: collection - the collection to decorate, must not be null Parameters: lock - the lock object to use, must not be null throws: IllegalArgumentException - if the collection is null |
clear | public void clear()(Code) | | |
decorate | public static Collection decorate(Collection coll)(Code) | | Factory method to create a synchronized collection.
Parameters: coll - the collection to decorate, must not be null a new synchronized collection throws: IllegalArgumentException - if collection is null |
hashCode | public int hashCode()(Code) | | |
isEmpty | public boolean isEmpty()(Code) | | |
iterator | public Iterator iterator()(Code) | | Iterators must be manually synchronized.
synchronized (coll) {
Iterator it = coll.iterator();
// do stuff with iterator
}
an iterator that must be manually synchronized on the collection |
|
|