例如在springmvc的controller中
    public class EnchashmentController extends BaseController {
            private int a = 0;
            
            @requestMapping("")
            public ModelAndView add(){
                a++;
                return null;
            }
    }每一个请求都在这里都执行一次a加一操作,1万次请求(并发)甚至更多次以后,这里输出的a是否就是 10000 或者 100000呢?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
应该说a++不是线程安全的
AtomicInteger应该是你要的答案
不安全。。。。