in hugegraph-common/src/main/java/org/apache/hugegraph/concurrent/AtomicLock.java [55:73]
public boolean lock(int retries) {
// The interval between retries is exponential growth, most wait
// interval is 2^(retries-1)s. If retries=0, don't retry.
if (retries < 0 || retries > 10) {
throw new IllegalArgumentException(String.format(
"Locking retry times should be in [0, 10], but got %d",
retries));
}
boolean isLocked = false;
try {
for (int i = 0; !(isLocked = this.tryLock()) && i < retries; i++) {
Thread.sleep(1000 * (1L << i));
}
} catch (InterruptedException ignored) {
LOG.info("Thread sleep is interrupted.");
}
return isLocked;
}