public String getID() throws IOException { try { lock.lock(); // If ID is 0, read initial value from file if possible if (!minimizeReads || !used) { long readInitialValue = readInitialValue(getFilePath()); if (readInitialValue >= 0) { set(readInitialValue); } used = true; } String id = super.getID(); // The id held in the file is always <increment> larger so that // the ID is still unique after a restart. writeNextValue(Long.parseLong(id) + getIncrement()); return id; } finally { lock.unlock(); } }
public String getID() throws IOException { try { lock.lock(); // If ID is 0, read initial value from file if possible if (!minimizeReads || !used) { long readInitialValue = readInitialValue(getFilePath()); if (readInitialValue >= 0) { set(readInitialValue); } used = true; } String id = super.getID(); // The id held in the file is always <increment> larger so that // the ID is still unique after a restart. writeNextValue(Long.parseLong(id) + getIncrement()); return id; } finally { lock.unlock(); } }