Class TSynchronizedFloatFloatMaps



  • public class TSynchronizedFloatFloatMaps
    extends Object
    • Method Detail

      • wrap

        public static TFloatFloatMap wrap(TFloatFloatMap m)
        Returns a synchronized (thread-safe) Trove map backed by the specified map. In order to guarantee serial access, it is critical that all access to the backing map is accomplished through the returned map.

        It is imperative that the user manually synchronize on the returned map when iterating over any of its collection views:

          TFloatFloatMap m = TSynchronizedFloatFloatMaps.wrap( new TFloatFloatHashMap() );
              ...
          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.

        Parameters:
        m - the map to be "wrapped" in a synchronized map.
        Returns:
        a synchronized view of the specified map.