代码
@GetMapping("/sync")
public Callable<Object> test(@RequestParam Long userId) {
long tomcatStart = System.currentTimeMillis();
Callable<Object> callable = new Callable<Object>() {
@Override
public Object call() throws Exception {
long childStart = System.currentTimeMillis();
System.out.println("child cost=" + (System.currentTimeMillis() - childStart));
return userId;
}
};
System.out.println("tomcat cost=" + (System.currentTimeMillis() - tomcatStart));
return callable;
}
参考文档
https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc-ann-async-deferredresult