java.lang.Object | +--org.apache.commons.collections.collection.SynchronizedCollectionAll Implemented Interfaces:
Collection | The collection to decorate |
Object | The object to lock on, needed for List/SortedSet views |
SynchronizedCollection(Collection collection) Constructor that wraps (not copies). |
SynchronizedCollection(Collection collection, Object lock) Constructor that wraps (not copies). |
boolean | add(Object object) |
boolean | addAll(Collection coll) |
void | clear() |
boolean | contains(Object object) |
boolean | containsAll(Collection coll) |
static Collection | decorate(Collection coll) Factory method to create a synchronized collection. |
boolean | equals(Object object) |
int | hashCode() |
boolean | isEmpty() |
Iterator | iterator() Iterators must be manually synchronized. |
boolean | remove(Object object) |
boolean | removeAll(Collection coll) |
boolean | retainAll(Collection coll) |
int | size() |
Object[] | toArray() |
Object[] | toArray(Object[] object) |
String | toString() |
protected final Collection collection
protected final Object lock
protected SynchronizedCollection(Collection collection, Object lock)
- if the collection is nullprotected SynchronizedCollection(Collection collection)
- if the collection is nullpublic boolean add(Object object)
public boolean addAll(Collection coll)
public void clear()
public boolean contains(Object object)
public boolean containsAll(Collection coll)
public static Collection decorate(Collection coll)
- if collection is nullpublic boolean equals(Object object)
public int hashCode()
public boolean isEmpty()
public Iterator iterator()
synchronized (coll) { Iterator it = coll.iterator(); // do stuff with iterator
public boolean remove(Object object)
public boolean removeAll(Collection coll)
public boolean retainAll(Collection coll)
public int size()
public Object[] toArray()
public Object[] toArray(Object[] object)
public String toString()
Collection
to synchronize its behaviour for a multi-threaded environment. Iterators must be manually synchronized: