java如何生成12位序列號(hào)?
private static int maxvaluefive=99999999;
private static int minvaluefive=0;
private static AtomicInteger atomic = new AtomicInteger(minvaluefive);
/** 生成序列號(hào) */
static String getSeqFive(int coverPad) {
for (;;) {
int current = atomic.get();
int newValue = current >= maxvaluefive ? minvaluefive : current + 1;
if (atomic.compareAndSet(current, newValue)) {
return StringUtils.leftPad(String.valueOf(current), coverPad, "0");
}
}
}