public class TSynchronizedFloatObjectMaps extends Object
| Modifier and Type | Method and Description |
|---|---|
static <V> TFloatObjectMap |
wrap(TFloatObjectMap
Returns a synchronized (thread-safe) Trove map backed by the specified map.
|
public static <V> TFloatObjectMap<V> wrap(TFloatObjectMap <V> m)
It is imperative that the user manually synchronize on the returned map when iterating over any of its collection views:
TFloatObjectMap m = TSynchronizedFloatObjectMaps.wrap( new TFloatObjectHashMap() );
...
TFloatSet s = m.keySet(); // Needn't be in synchronized block
...
synchronized( m ) { // Synchronizing on m, not s!
TFloatIterator i = s.iterator(); // Must be in synchronized block
while ( i.hasNext() )
foo( i.next() );
}
Failure to follow this advice may result in non-deterministic behavior.
The returned map will be serializable if the specified map is serializable.
m - the map to be "wrapped" in a synchronized map.