springboot 异步执行程序

 

 

启动类开启异步调用

springboot 异步执行程序

 

异步类

springboot 异步执行程序

springboot 异步执行程序

如果上面按同步执行的话,总用时会时1000+700+600 =2300ms,异步的话,应该是1000ms

 

 

测试异步

 

springboot 异步执行程序

springboot 异步执行程序

springboot 异步执行程序

 

 

springboot 异步执行程序

 

为什么多出8ms呢,是因为循环用了。

 

把方法的@Async   注释掉后的结果
springboot 异步执行程序

 

 

 

 

异步使用场景

springboot 异步执行程序

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2021-05-02
猜你喜欢
  • 2021-05-24
  • 2021-12-14
  • 2021-09-14
  • 2022-12-23
  • 2021-10-04
  • 2021-10-23
  • 2021-10-15
相关资源
相似解决方案