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 anotherCollectionto 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 booleanadd(Object object)Deprecated.booleanaddAll(Collection coll)Deprecated.voidclear()Deprecated.booleancontains(Object object)Deprecated.booleancontainsAll(Collection coll)Deprecated.static Collectiondecorate(Collection coll)Deprecated.Factory method to create a synchronized collection.booleanequals(Object object)Deprecated.inthashCode()Deprecated.booleanisEmpty()Deprecated.Iteratoriterator()Deprecated.Iterators must be manually synchronized.booleanremove(Object object)Deprecated.booleanremoveAll(Collection coll)Deprecated.booleanretainAll(Collection coll)Deprecated.intsize()Deprecated.Object[]toArray()Deprecated.Object[]toArray(Object[] object)Deprecated.StringtoString()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:
addin interfaceCollection
-
addAll
public boolean addAll(Collection coll)
Deprecated.- Specified by:
addAllin interfaceCollection
-
clear
public void clear()
Deprecated.- Specified by:
clearin interfaceCollection
-
contains
public boolean contains(Object object)
Deprecated.- Specified by:
containsin interfaceCollection
-
containsAll
public boolean containsAll(Collection coll)
Deprecated.- Specified by:
containsAllin interfaceCollection
-
isEmpty
public boolean isEmpty()
Deprecated.- Specified by:
isEmptyin interfaceCollection
-
iterator
public Iterator iterator()
Deprecated.Iterators must be manually synchronized.synchronized (coll) { Iterator it = coll.iterator(); // do stuff with iterator }- Specified by:
iteratorin interfaceCollection- Specified by:
iteratorin interfaceIterable- Returns:
- an iterator that must be manually synchronized on the collection
-
toArray
public Object[] toArray()
Deprecated.- Specified by:
toArrayin interfaceCollection
-
toArray
public Object[] toArray(Object[] object)
Deprecated.- Specified by:
toArrayin interfaceCollection
-
remove
public boolean remove(Object object)
Deprecated.- Specified by:
removein interfaceCollection
-
removeAll
public boolean removeAll(Collection coll)
Deprecated.- Specified by:
removeAllin interfaceCollection
-
retainAll
public boolean retainAll(Collection coll)
Deprecated.- Specified by:
retainAllin interfaceCollection
-
size
public int size()
Deprecated.- Specified by:
sizein interfaceCollection
-
equals
public boolean equals(Object object)
Deprecated.- Specified by:
equalsin interfaceCollection- Overrides:
equalsin classObject
-
hashCode
public int hashCode()
Deprecated.- Specified by:
hashCodein interfaceCollection- Overrides:
hashCodein classObject
-
-