public LockResource get(K key, LockMode mode) {
    ValNode valNode = getValNode(key);
    ReentrantReadWriteLock lock = valNode.mValue;
    switch (mode) {
      case READ:
        return new RefCountLockResource(lock.readLock(), true, valNode.mRefCount);
      case WRITE:
        return new RefCountLockResource(lock.writeLock(), true, valNode.mRefCount);
      default:
        throw new IllegalStateException("Unknown lock mode: " + mode);
    }
  }
public LockResource get ( K key , LockMode mode ) { ValNode valNode = getValNode ( key ) ; ReentrantReadWriteLock lock = valNode . mValue ; switch ( mode ) { case READ : return new RefCountLockResource ( lock . readLock ( ) , true , valNode . mRefCount ) ; case WRITE : return new RefCountLockResource ( lock . writeLock ( ) , true , valNode . mRefCount ) ; default : throw new IllegalStateException ( "Unknown lock mode: " + mode ) ; } }
Locks the specified key in the specified mode.

@param key the key to lock
@param mode the mode to lock in
@return a lock resource which must be closed to unlock the key