public class UniqueThreadIdGenerator {
private static final AtomicInteger uniqueId = new AtomicInteger(0);
private static final ThreadLocal < Integer > uniqueNum =
new ThreadLocal < Integer > () {
@Override protected Integer initialValue() {
return uniqueId.getAndIncrement();
}
};
public static int getCurrentThreadId() {
// uniqueId is right? or is uniqueNum ?
return uniqueId.get();
}
} // UniqueThreadIdGenerator
getCurrentThreadId() uniqueId is right?I think uniqueNum is right
learn from each other about Threadlocal~~