Java单例生成序列号
public class Seqence6bit { private int seq = 100000; private Seqence6bit() {
}
private static class Seqence6bitContainer {
private static Seqence6bit instance = new Seqence6bit();
}
public static Seqence6bit getInstance() {
return Seqence6bitContainer.instance;
}
public synchronized String getSeq() {
this.seq++;
if (this.seq >= 1000000) {
this.seq = 100000;
return "100000";
}
return String.valueOf(seq);
}
}