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.
collection, lock
Modifier | Constructor and Description |
---|---|
protected |
SynchronizedList(List list)
Constructor that wraps (not copies).
|
protected |
SynchronizedList(List list,
Object lock)
Constructor that wraps (not copies).
|
Modifier and Type | Method and Description |
---|---|
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
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, replaceAll, retainAll, size, sort, spliterator, toArray, toArray
parallelStream, removeIf, stream
protected SynchronizedList(List list)
list
- the list to decorate, must not be nullIllegalArgumentException
- if list is nullprotected SynchronizedList(List list, Object lock)
list
- the list to decorate, must not be nulllock
- the lock to use, must not be nullIllegalArgumentException
- if list is nullpublic static List decorate(List list)
list
- the list to decorate, must not be nullIllegalArgumentException
- if list is nullprotected List getList()
public boolean addAll(int index, Collection coll)
public int lastIndexOf(Object object)
lastIndexOf
in interface List
public ListIterator listIterator()
synchronized (coll) { ListIterator it = coll.listIterator(); // do stuff with iterator }
listIterator
in interface List
public ListIterator listIterator(int index)
synchronized (coll) { ListIterator it = coll.listIterator(3); // do stuff with iterator }
listIterator
in interface List
Copyright © 2001–2017 The Apache Software Foundation. All rights reserved.