code: public void lock() throws IOException {
      for (int i = 0; i < LOCK_MAX_RETRIES; ++i) {
        try {
          fileLock = channel.tryLock(0, 1, false);
          break;
        } catch (OverlappingFileLockException e) {
          OLogManager.instance().debug(this,
              "Cannot open file '" + osFile.getAbsolutePath() + "' because it is locked. Waiting %d ms and retrying %d/%d...",
              LOCK_WAIT_TIME, i, LOCK_MAX_RETRIES);
  
          // FORCE FINALIZATION TO COLLECT ALL THE PENDING BUFFERS
          OMemoryWatchDog.freeMemory(LOCK_WAIT_TIME);
        }
      }
  
      if (fileLock == null)
        throw new OLockException(
            "File '"
                + osFile.getPath()
                + "' is locked by another process, maybe the database is in use by another process. Use the remote mode with a OrientDB server to allow multiple access to the same database.");
    }
docs: /*
  (non-Javadoc)
  
  @see com.orientechnologies.orient.core.storage.fs.OFileAAA#lock()