private RegularFile getOrCreateRegularFileWithWriteLock(
      JimfsPath path, Set<OpenOption> options, FileAttribute<?>[] attrs) throws IOException {
    store.writeLock().lock();
    try {
      File file = createFile(path, store.regularFileCreator(), options.contains(CREATE_NEW), attrs);
      // the file already existed but was not a regular file
      if (!file.isRegularFile()) {
        throw new FileSystemException(path.toString(), null, "not a regular file");
      }
      return open((RegularFile) file, options);
    } finally {
      store.writeLock().unlock();
    }
  }
Gets or creates a new regular file with a write lock (assuming the file does not exist).
jimfs/src/main/java/com/google/common/jimfs/FileSystemView.java