Java单例生成序列号

2014-11-24 02:08:34 · 作者: · 浏览: 0

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);

}

}