原子值:主要用于缓存中唯一的要求,比如队伍,要分配一个 id,并且该id不保存数据库.每次重启服务器,都从指定的值开始.
尝试使用了AtomicInteger这个类,感觉使用起来很爽,特别适用于高并发访问
public static AtomicInteger teamID = new AtomicInteger();
Integer tID = teamID.incrementAndGet(); 获取下一个id
尝试使用了AtomicInteger这个类,感觉使用起来很爽,特别适用于高并发访问
public static AtomicInteger teamID = new AtomicInteger();
Integer tID = teamID.incrementAndGet(); 获取下一个id