|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.collections15.collection.SynchronizedCollection<E>
public class SynchronizedCollection<E>
Decorates another Collection to synchronize its behaviour
for a multi-threaded environment.
synchronized (coll) {
Iterator it = coll.iterator();
// do stuff with iterator
}
This class is Serializable from Commons Collections 3.1.
| Field Summary | |
|---|---|
protected Collection<E> |
collection
The collection to decorate |
protected Object |
lock
The object to lock on, needed for List/SortedSet views |
| Constructor Summary | |
|---|---|
protected |
SynchronizedCollection(Collection<E> collection)
Constructor that wraps (not copies). |
protected |
SynchronizedCollection(Collection<E> collection,
Object lock)
Constructor that wraps (not copies). |
| Method Summary | ||
|---|---|---|
boolean |
add(E object)
|
|
boolean |
addAll(Collection<? extends E> coll)
|
|
void |
clear()
|
|
boolean |
contains(Object object)
|
|
boolean |
containsAll(Collection<?> coll)
|
|
static
|
decorate(Collection<E> coll)
Factory method to create a synchronized collection. |
|
boolean |
equals(Object object)
|
|
int |
hashCode()
|
|
boolean |
isEmpty()
|
|
Iterator<E> |
iterator()
Iterators must be manually synchronized. |
|
boolean |
remove(Object object)
|
|
boolean |
removeAll(Collection<?> coll)
|
|
boolean |
retainAll(Collection<?> coll)
|
|
int |
size()
|
|
Object[] |
toArray()
|
|
|
toArray(T[] object)
|
|
String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final Collection<E> collection
protected final Object lock
| Constructor Detail |
|---|
protected SynchronizedCollection(Collection<E> collection)
collection - the collection to decorate, must not be null
IllegalArgumentException - if the collection is null
protected SynchronizedCollection(Collection<E> collection,
Object lock)
collection - the collection to decorate, must not be nulllock - the lock object to use, must not be null
IllegalArgumentException - if the collection is null| Method Detail |
|---|
public static <E> Collection<E> decorate(Collection<E> coll)
coll - the collection to decorate, must not be null
IllegalArgumentException - if collection is nullpublic boolean add(E object)
add in interface Collection<E>public boolean addAll(Collection<? extends E> coll)
addAll in interface Collection<E>public void clear()
clear in interface Collection<E>public boolean contains(Object object)
contains in interface Collection<E>public boolean containsAll(Collection<?> coll)
containsAll in interface Collection<E>public boolean isEmpty()
isEmpty in interface Collection<E>public Iterator<E> iterator()
synchronized (coll) {
Iterator it = coll.iterator();
// do stuff with iterator
}
iterator in interface Iterable<E>iterator in interface Collection<E>public Object[] toArray()
toArray in interface Collection<E>public <T> T[] toArray(T[] object)
toArray in interface Collection<E>public boolean remove(Object object)
remove in interface Collection<E>public boolean removeAll(Collection<?> coll)
removeAll in interface Collection<E>public boolean retainAll(Collection<?> coll)
retainAll in interface Collection<E>public int size()
size in interface Collection<E>public boolean equals(Object object)
equals in interface Collection<E>equals in class Objectpublic int hashCode()
hashCode in interface Collection<E>hashCode in class Objectpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||