org.apache.commons.collections.list
Class SynchronizedList
- Collection, List, Serializable
public class SynchronizedList
implements List
Decorates another
List
to synchronize its behaviour
for a multi-threaded environment.
Methods are synchronized, then forwarded to the decorated list.
This class is Serializable from Commons Collections 3.1.
$Revision: 1.5 $ $Date: 2004/06/03 22:02:13 $
void | add(int index, Object object)
|
boolean | addAll(int index, Collection coll)
|
static List | decorate(List list) - Factory method to create a synchronized list.
|
Object | get(int index)
|
protected List | getList() - Gets the decorated list.
|
int | indexOf(Object object)
|
int | lastIndexOf(Object object)
|
ListIterator | listIterator() - Iterators must be manually synchronized.
|
ListIterator | listIterator(int index) - Iterators must be manually synchronized.
|
Object | remove(int index)
|
Object | set(int index, Object object)
|
List | subList(int fromIndex, int toIndex)
|
add , addAll , clear , contains , containsAll , decorate , equals , hashCode , isEmpty , iterator , remove , removeAll , retainAll , size , toArray , toArray , toString |
SynchronizedList
protected SynchronizedList(List list)
Constructor that wraps (not copies).
list
- the list to decorate, must not be null
SynchronizedList
protected SynchronizedList(List list,
Object lock)
Constructor that wraps (not copies).
list
- the list to decorate, must not be nulllock
- the lock to use, must not be null
add
public void add(int index,
Object object)
addAll
public boolean addAll(int index,
Collection coll)
decorate
public static List decorate(List list)
Factory method to create a synchronized list.
list
- the list to decorate, must not be null
get
public Object get(int index)
getList
protected List getList()
Gets the decorated list.
indexOf
public int indexOf(Object object)
lastIndexOf
public int lastIndexOf(Object object)
listIterator
public ListIterator listIterator()
Iterators must be manually synchronized.
synchronized (coll) {
ListIterator it = coll.listIterator();
// do stuff with iterator
}
- an iterator that must be manually synchronized on the collection
listIterator
public ListIterator listIterator(int index)
Iterators must be manually synchronized.
synchronized (coll) {
ListIterator it = coll.listIterator(3);
// do stuff with iterator
}
- an iterator that must be manually synchronized on the collection
remove
public Object remove(int index)
set
public Object set(int index,
Object object)
subList
public List subList(int fromIndex,
int toIndex)
Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.