public void xxHandle(){
long startTime = System.currentTimeMillis();
sendMqMsg();
System.out.println("cost: " + (System.currentTimeMillis() - startTime));
}
@Async
public void sendMqMsg(){
相关业务代码;
}
虽然你开了@Async 走了并发 但是你xxHandle,也会占用线程,多个线程时候也会存在切换上下文,相当于xxHandle和你的@Async开启的并发线程都会参与到cpu时间片分配的竞争中,可能在执行打印前被其他的并发线程抢走时间片,所以就变慢。
你这么写,你觉得他可能是异步的嘛?😓内部直接调用方法就不走代理,aop失效,异步变同步