code: private synchronized boolean tryServerLock() throws IOException {
          if (!lockFile.exists() || lockFileChannel == null)
              return false;
  
          boolean lockObtained = true;
  
          try {
              serverLock = lockFileChannel.tryLock();
  
              // if server lock is not valid, it could not be obtained
              if (serverLock == null || !serverLock.isValid())
                  lockObtained = false;
          } catch (OverlappingFileLockException e) {
              lockObtained = false;
          } catch (IOException e) {
              lockObtained = false;
          } finally {
              // make sure we release so the other process can obtain the lock file
              if (serverLock != null)
                  serverLock.release();
          }
  
          return lockObtained;
      }
docs: Try to obtain the server lock file: this immediately releases
  if it is able to obtain the file.
  
  @return true if lock could be obtained
  @throws IOException if an exception occurred while trying the lock.