Class SynchronizedCollection
- java.lang.Object
-
- org.apache.commons.collections.collection.SynchronizedCollection
-
- All Implemented Interfaces:
Serializable
,Iterable
,Collection
- Direct Known Subclasses:
SynchronizedBag
,SynchronizedBuffer
,SynchronizedList
,SynchronizedSet
,SynchronizedSortedSet
@Deprecated(since="2021-04-30") public class SynchronizedCollection extends Object implements Collection, Serializable
Deprecated.Commons Collections 3 is in maintenance mode. Commons Collections 4 should be used instead.Decorates anotherCollection
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.
- Since:
- Commons Collections 3.0
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
add(Object object)
Deprecated.boolean
addAll(Collection coll)
Deprecated.void
clear()
Deprecated.boolean
contains(Object object)
Deprecated.boolean
containsAll(Collection coll)
Deprecated.static Collection
decorate(Collection coll)
Deprecated.Factory method to create a synchronized collection.boolean
equals(Object object)
Deprecated.int
hashCode()
Deprecated.boolean
isEmpty()
Deprecated.Iterator
iterator()
Deprecated.Iterators must be manually synchronized.boolean
remove(Object object)
Deprecated.boolean
removeAll(Collection coll)
Deprecated.boolean
retainAll(Collection coll)
Deprecated.int
size()
Deprecated.Object[]
toArray()
Deprecated.Object[]
toArray(Object[] object)
Deprecated.String
toString()
Deprecated.-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Method Detail
-
decorate
public static Collection decorate(Collection coll)
Deprecated.Factory method to create a synchronized collection.- Parameters:
coll
- the collection to decorate, must not be null- Returns:
- a new synchronized collection
- Throws:
IllegalArgumentException
- if collection is null
-
add
public boolean add(Object object)
Deprecated.- Specified by:
add
in interfaceCollection
-
addAll
public boolean addAll(Collection coll)
Deprecated.- Specified by:
addAll
in interfaceCollection
-
clear
public void clear()
Deprecated.- Specified by:
clear
in interfaceCollection
-
contains
public boolean contains(Object object)
Deprecated.- Specified by:
contains
in interfaceCollection
-
containsAll
public boolean containsAll(Collection coll)
Deprecated.- Specified by:
containsAll
in interfaceCollection
-
isEmpty
public boolean isEmpty()
Deprecated.- Specified by:
isEmpty
in interfaceCollection
-
iterator
public Iterator iterator()
Deprecated.Iterators must be manually synchronized.synchronized (coll) { Iterator it = coll.iterator(); // do stuff with iterator }
- Specified by:
iterator
in interfaceCollection
- Specified by:
iterator
in interfaceIterable
- Returns:
- an iterator that must be manually synchronized on the collection
-
toArray
public Object[] toArray()
Deprecated.- Specified by:
toArray
in interfaceCollection
-
toArray
public Object[] toArray(Object[] object)
Deprecated.- Specified by:
toArray
in interfaceCollection
-
remove
public boolean remove(Object object)
Deprecated.- Specified by:
remove
in interfaceCollection
-
removeAll
public boolean removeAll(Collection coll)
Deprecated.- Specified by:
removeAll
in interfaceCollection
-
retainAll
public boolean retainAll(Collection coll)
Deprecated.- Specified by:
retainAll
in interfaceCollection
-
size
public int size()
Deprecated.- Specified by:
size
in interfaceCollection
-
equals
public boolean equals(Object object)
Deprecated.- Specified by:
equals
in interfaceCollection
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()
Deprecated.- Specified by:
hashCode
in interfaceCollection
- Overrides:
hashCode
in classObject
-
-