java.lang.Object |
↳ |
org.apache.commons.collections.collection.SynchronizedCollection |
Known Direct Subclasses
SynchronizedBag |
Decorates another Bag to synchronize its behaviour
for a multi-threaded environment. |
SynchronizedBuffer |
Decorates another Buffer to synchronize its behaviour
for a multi-threaded environment. |
SynchronizedList |
Decorates another List to synchronize its behaviour
for a multi-threaded environment. |
SynchronizedSet |
Decorates another Set to synchronize its behaviour for a
multi-threaded environment. |
SynchronizedSortedSet |
Decorates another SortedSet to synchronize its behaviour
for a multi-threaded environment. |
|
Known Indirect Subclasses
|
Class Overview
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.
Summary
Fields |
protected
final
Collection |
collection |
The collection to decorate |
protected
final
Object |
lock |
The object to lock on, needed for List/SortedSet views |
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
From interface
java.lang.Iterable
|
From interface
java.util.Collection
abstract
boolean
|
add(E arg0)
|
abstract
boolean
|
addAll(Collection<? extends E> arg0)
|
abstract
void
|
clear()
|
abstract
boolean
|
contains(Object arg0)
|
abstract
boolean
|
containsAll(Collection<?> arg0)
|
abstract
boolean
|
equals(Object arg0)
|
abstract
int
|
hashCode()
|
abstract
boolean
|
isEmpty()
|
abstract
Iterator<E>
|
iterator()
|
abstract
boolean
|
remove(Object arg0)
|
abstract
boolean
|
removeAll(Collection<?> arg0)
|
abstract
boolean
|
retainAll(Collection<?> arg0)
|
abstract
int
|
size()
|
abstract
<T>
T[]
|
toArray(T[] arg0)
|
abstract
Object[]
|
toArray()
|
|
Fields
protected
final
Collection
collection
The collection to decorate
protected
final
Object
lock
The object to lock on, needed for List/SortedSet views
Protected Constructors
protected
SynchronizedCollection
(Collection collection)
Constructor that wraps (not copies).
Parameters
collection
| the collection to decorate, must not be null |
protected
SynchronizedCollection
(Collection collection, Object lock)
Constructor that wraps (not copies).
Parameters
collection
| the collection to decorate, must not be null |
lock
| the lock object to use, must not be null |
Public Methods
public
boolean
add
(Object object)
public
boolean
contains
(Object object)
Factory method to create a synchronized collection.
Parameters
coll
| the collection to decorate, must not be null |
Returns
- a new synchronized collection
public
boolean
equals
(Object object)
public
boolean
isEmpty
()
public
Iterator
iterator
()
Iterators must be manually synchronized.
synchronized (coll) {
Iterator it = coll.iterator();
// do stuff with iterator
}
Returns
- an iterator that must be manually synchronized on the collection
public
boolean
remove
(Object object)