gausssoft.collections
Class SynchronizedSet
java.lang.Object
|
+--gausssoft.collections.SynchronizedCollection
|
+--gausssoft.collections.SynchronizedSet
- All Implemented Interfaces:
- Collection, Serializable, Set
- Direct Known Subclasses:
- SynchronizedSortedSet
- public class SynchronizedSet
- extends SynchronizedCollection
- implements Set
The SynchronizedSet class is used to synchronize all operations on a
Set
object on a particular object.
Each method of this implementation synchronizes on a specified object specified
at construction time, and then calls the method of the same signature
of the backing set. Each instance is serializable only if the backing
set and mutex is serializable.
This is similar to the synchronization methods in Collections
, but
this implementation allows you to choose what object to synchronize on, and allows
subclassing.
- Author:
- Allan Crooks
- See Also:
Set
,
Collections
, Serialized Form
Field Summary |
protected Set |
root
Backing set. |
Methods inherited from class gausssoft.collections.SynchronizedCollection |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString |
Methods inherited from interface java.util.Set |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
root
protected final Set root
- Backing set.
SynchronizedSet
public SynchronizedSet(Set root,
Object mutex)
- Creates a new SynchronizedSet.
- Parameters:
root
- The set to use as the backing set.mutex
- The object to synchronize operations on.- Throws:
NullPointerException
- If root is null
.
SynchronizedSet
public SynchronizedSet(Set root)
- Creates a new SynchronizedSet.
The object constructed will synchronize all operations on itself.
- Parameters:
root
- The set to use as the backing set.- Throws:
NullPointerException
- If root is null
.