public boolean lockWithRetries(){
  try {
    for (int i=0; i < retryCount; i++) {
      if (lock()) {
        return true;
      }
 else {
        Thread.sleep(retryTimeout * 1000L);
      }
    }
  }
 catch (  InterruptedException e) {
    return false;
  }
  return false;
}

public boolean lockWithRetries ( ) { try { for ( int i = 0 ; i < retryCount ; i ++ ) { if ( lock ( ) ) { return true ; } else { Thread . sleep ( retryTimeout * 1000L ) ; } } } catch ( InterruptedException e ) { return false ; } return false ; }
api for enabling the locking of file with retries .
