package com.ctx.controller;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TomcatController {
@GetMapping("/fun")
public Callable<String> fun() throws InterruptedException, ExecutionException {
System.out.println("===================进入主方法:"+System.currentTimeMillis());
Callable<String> callable = new Callable<String>() {
@Override
public String call() throws Exception {
System.out.println("===================进入子方法:"+System.currentTimeMillis());
//延时1秒(这里写业务,以延迟一秒来表示接口消耗的时间。)
Thread.sleep(1000);
System.out.println("===================完成子方法:"+System.currentTimeMillis());
return "业务方法执行完毕。";
}
};
System.out.println("===================完成主方法:"+System.currentTimeMillis());
return callable;
}
@GetMapping("/fun2")
public String fun2() throws InterruptedException {
System.out.println("===================进入主方法:"+System.currentTimeMillis());
//延时1秒
Thread.sleep(1000);
System.out.println("===================完成主方法:"+System.currentTimeMillis());
return "success";
}
}
提高Tomcat吞吐量
猜你喜欢
转载自blog.csdn.net/qq_39706570/article/details/107993944
今日推荐
周排行