首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

生成近乎的uuid

2013-06-26 
生成近似的uuid?private static long tmpID 0??private static boolean tmpIDlocked false??private

生成近似的uuid

?private static long tmpID = 0;
?
?private static boolean tmpIDlocked = false;

?
?private static long getUniqueId() {
??long ltime = 0;
??while (true) {
???if(tmpIDlocked == false) {
????tmpIDlocked= true;
????ltime= Long.valueOf(new SimpleDateFormat("yyMMddhhmmssSSS")
??????.format(newDate()).toString()) * 10000;
????if(tmpID < ltime) {
?????tmpID= ltime;
????}else {
?????tmpID= tmpID + 1;
?????ltime= tmpID;
????}
????tmpIDlocked= false;
????returnltime;
???}
??}
?}

热点排行