有的时候博客内容会有变动,首发博客是最新的,其他博客地址可能会未同步,认准
https://blog.zysicyj.top
java
package com.nari.common.utils;
import java.util.concurrent.atomic.AtomicInteger;
public class IdUtilV2 {
private static final AtomicInteger ids = new AtomicInteger(1);
private IdUtilV2() {
}
public static String getIdStr() {
return getId().toString();
}
public static Long getId() {
return System.nanoTime() + Thread.currentThread().getId() + (ids.getAndIncrement());
}
}
本文由mdnice多平台发布