Package com.naver.ads.collect
Class SynchronizedCollection
-
- All Implemented Interfaces:
-
kotlin.collections.Collection,kotlin.collections.Iterable,kotlin.collections.MutableCollection,kotlin.collections.MutableIterable
public class SynchronizedCollection<E extends Object> implements Collection<E>
Decorates another MutableCollection to synchronize its behavior for a multithreaded environment.
Iterators must be manually synchronized:
synchronized (coll) { Iterator it = coll.iterator(); // do stuff with iterator }
-
-
Constructor Summary
Constructors Constructor Description SynchronizedCollection(Collection<E> collection, Object lock)Constructor that wraps (not copies). SynchronizedCollection(Collection<E> collection)Constructor that wraps (not copies).
-
Method Summary
Modifier and Type Method Description IntegergetSize()final ObjectgetLock()the lock object to use, must not be null Collection<E>decorated()Gets the collection being decorated. Booleanadd(E element)BooleanaddAll(Collection<E> elements)Unitclear()Booleancontains(E element)BooleancontainsAll(Collection<E> elements)BooleanisEmpty()Iterator<E>iterator()Iterators must be manually synchronized. Booleanremove(E element)BooleanremoveAll(Collection<E> elements)BooleanretainAll(Collection<E> elements)Booleanequals(Object other)IntegerhashCode()StringtoString()-
-
Constructor Detail
-
SynchronizedCollection
SynchronizedCollection(Collection<E> collection, Object lock)
Constructor that wraps (not copies).
-
SynchronizedCollection
SynchronizedCollection(Collection<E> collection)
Constructor that wraps (not copies).
-
-
Method Detail
-
decorated
Collection<E> decorated()
Gets the collection being decorated.
- Returns:
the decorated collection
-
addAll
Boolean addAll(Collection<E> elements)
-
containsAll
Boolean containsAll(Collection<E> elements)
-
iterator
Iterator<E> iterator()
Iterators must be manually synchronized.
synchronized (coll) { Iterator it = coll.iterator(); // do stuff with iterator }- Returns:
an iterator that must be manually synchronized on the collection
-
removeAll
Boolean removeAll(Collection<E> elements)
-
retainAll
Boolean retainAll(Collection<E> elements)
-
-
-
-