@RestController
public class helloworld {
private int count;
@RequestMapping("/hello")
public String hello(){
count++;
return "hello world";
}}
假设上面这个controller是多例的,有没有这么一个场景,在我项目运行时,同时有两个线程持有helloworld同一个实例? 就是持有同一个变量count的副本拷贝。
如果是单例模式,那么毫无疑问会持有同一个实例,那如果是多例,小明和小王两个人同时运行我的项目,做什么操作才会有线程安全问题,才会有同一份helloworld实例呢?
不知道我有没有表述清楚