org.apache.commons.collections.list
public class SynchronizedList extends SynchronizedCollection implements List
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.
Since: Commons Collections 3.0
Version: $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
Constructor Summary | |
---|---|
protected | SynchronizedList(List list)
Constructor that wraps (not copies).
|
protected | SynchronizedList(List list, Object lock)
Constructor that wraps (not copies).
|
Method Summary | |
---|---|
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) |
Parameters: list the list to decorate, must not be null
Throws: IllegalArgumentException if list is null
Parameters: list the list to decorate, must not be null lock the lock to use, must not be null
Throws: IllegalArgumentException if list is null
Parameters: list the list to decorate, must not be null
Throws: IllegalArgumentException if list is null
Returns: the decorated list
synchronized (coll) { ListIterator it = coll.listIterator(); // do stuff with iterator }Returns: an iterator that must be manually synchronized on the collection
synchronized (coll) { ListIterator it = coll.listIterator(3); // do stuff with iterator }Returns: an iterator that must be manually synchronized on the collection