一、Callable(Runnable)异步处理请求

       SpringBoot异步处理服务请求

 

@GetMapping("/async")
    public ResultVO asyncTest() throws Exception {
        log.info("主线程start");
        Callable<ResultVO> result = new Callable<ResultVO>() {
            @Override
            public ResultVO call() throws Exception {
                log.info("副线程start");
                Thread.sleep(15000);
                log.info("副线程end");
                return ResultVO.ofSuccess(null);
            }
        };

        log.info("主线程end");
        return result.call();
    }

业务逻辑在call()方法中实现。 

SpringBoot异步处理服务请求 

相关文章:

  • 2022-01-22
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-02-24
  • 2022-12-23
  • 2021-10-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2022-03-04
  • 2021-04-20
相关资源
相似解决方案