Chinaunix首页 | 论坛 | 博客
  • 博客访问: 543677
  • 博文数量: 17
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 2325
  • 用 户 组: 普通用户
  • 注册时间: 2004-10-26 16:15
文章分类

全部博文(17)

文章存档

2008年(17)

我的朋友

分类: Java

2008-06-16 14:59:19

Java的UUID是否适合大规模的并发环境?暂时使用UUID.randomUUID().hashCode()。
在网上搜到几篇使用AtomicLong实现的ID生成器的文章。难道是我的用法有误吗?
 

Use an AtomicLong:
class IdGenerator {
   private static AtomicLong id = new AtomicLong(0);
    
   public static long getNextId() {
       return id.incrementAndGet();
   }
}

阅读(3280) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~