servlet 计数器

servlet 计数器

private final long count;
public void service(){
    count++;
}

计数器执行 读取-修改-写入,实现递增操作,线程不安全修改为

private final AtomicLong count=new AtomicLong(0);
public void service(){
    count.incrementAndGet();
}
文章目录
|