Beispiel #1
0
 /**
  * Acquires a lock on the file. Does nothing if the correct lock has already been acquired.
  * Otherwise, releases an existing lock.
  *
  * @param shared shared/exclusive lock
  * @return success flag
  * @throws IOException I/O exception
  */
 private boolean lck(final boolean shared) throws IOException {
   if (fl != null && shared == fl.isShared()) return true;
   if (fl != null) fl.release();
   fl = file.getChannel().tryLock(0, Long.MAX_VALUE, shared);
   return fl != null;
 }