自己做了测试多个请求时串行执行得,很多博客说得是每个请求创建一个线程去处理,不需要等待上一个请求结束啊,有没有大神解释一下这个问题啊
下面是请求url得代码
private Integer testVar=0;
@RequestMapping("/testObject")
@ResponseBody
public Integer test() throws InterruptedException {
testVar++;
System.out.println(testVar+"start");
Thread.sleep(2000l);
System.out.println(testVar+"end");
return testVar;
}
下面是控制台打印结果
12start
12end
13start
13end
14start
14end
--------------------------------------
追加:我用得tomcat7,但是改成8也没用
---------------------------------------
TheWaSaiBoy说的对,感谢,用不同得浏览器测试结果正确,
就是说明同一个浏览器多次访问相同接口请求是串行执行不同客户端访问时并行得
执行结果如下,
1start
2start
3start
3end
3end
3end