@Override
  public long position() throws IOException {
    checkOpen();

    long pos;

    synchronized (this) {
      boolean completed = false;
      try {
        begin(); // don't call beginBlocking() because this method doesn't block
        if (!isOpen()) {
          return 0; // AsynchronousCloseException will be thrown
        }
        pos = this.position;
        completed = true;
      } finally {
        end(completed);
      }
    }

    return pos;
  }
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