Code example for FileLock

Methods: release

0
String msg = "hello from" + instanceName + " " + i + LINE_SEPARATOR;
      fos.write(msg.getBytes());
    } finally { 
      if (fileLock != null) {
        fileLock.release();
      } 
    } 
  } 
 
  static void printDotAndSleep(int i) throws InterruptedException {
    if (i % DOT_FREQ == 0) {
      System.out.print(".");
      Thread.sleep(delay);
    } 
    if (i % DOT_WITH_NEW_LINE_FREQ == 0) System.out.println("");
  } 
}