public V get ( K key ) throws E { // Quick check without locking. V value = mValues . get ( key ) ; if ( value != null ) { return value ; } // Check again with key lock held. Lock lock = mLockPool . get ( key ) ; lock . lock ( ) ; try { value = mValues . get ( key ) ; if ( value == null ) { try { value = create ( key ) ; mValues . put ( key , value ) ; } catch ( Exception e ) { // Workaround compiler bug. org . cojen . util . ThrowUnchecked . fire ( e ) ; } } } finally { lock . unlock ( ) ; } return value ; }
Returns a value for the given key which is lazily created and pooled . If multiple threads are requesting upon the same key concurrently at most one thread attempts to lazily create the value . The others wait for it to become available .