public class TSynchronizedDoubleSets extends Object
| Modifier and Type | Method and Description |
|---|---|
static TDoubleSet |
wrap(TDoubleSet
Returns a synchronized (thread-safe) Trove set backed by the specified set.
|
public static TDoubleSetwrap(TDoubleSet s)
It is imperative that the user manually synchronize on the returned set when iterating over it:
TDoubleSet s = TSynchronizedDoubleSets.wrap( new TDoubleHashSet() );
...
synchronized(s) {
TDoubleIterator i = s.iterator(); // Must be in the synchronized block
while ( i.hasNext() )
foo( i.next() );
}
Failure to follow this advice may result in non-deterministic behavior.
The returned set will be serializable if the specified set is serializable.
s - the set to be "wrapped" in a synchronized set.