@Override
  public int read(ByteBuffer dst, long position) throws IOException {
    checkNotNull(dst);
    Util.checkNotNegative(position, "position");
    checkOpen();
    checkReadable();

    int read = 0; // will definitely either be assigned or an exception will be thrown

    // no need to synchronize here; this method does not make use of the channel's position
    boolean completed = false;
    try {
      if (!beginBlocking()) {
        return 0; // AsynchronousCloseException will be thrown
      }
      file.readLock().lockInterruptibly();
      try {
        read = file.read(position, dst);
        file.setLastAccessTime(fileSystemState.now());
        completed = true;
      } finally {
        file.readLock().unlock();
      }
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    } finally {
      endBlocking(completed);
    }

    return read;
  }
Ends a blocking operation, throwing an exception if the thread was interrupted while blocking
or if the channel was closed from another thread.
jimfs/src/main/java/com/google/common/jimfs/JimfsFileChannel.java