wx-api icon indicating copy to clipboard operation
wx-api copied to clipboard

你好 我想请问下使用了@async为什么还要使用线程池?

Open seafeee opened this issue 2 years ago • 2 comments

作者你好,有点问题想请教你。对于您的项目 https://github.com/niefy/wx-api/blob/master/src/main/java/com/github/niefy/modules/wx/service/impl/TemplateMsgServiceImpl.java这一个service中,sendTemplateMsg方法使用用了 @async 注解,这个注解的本质不是使用了线程池吗?为什么代码里面还要手动利用线程池去执行发送消息的操作?经过尝试,如果去除 TaskExcutor.submit(),这个函数也能异步执行的,那这么写的目的是什么呢?望释疑,万分感谢

seafeee avatar May 19 '22 12:05 seafeee

哈哈,确实,直接加注解就行了,没必要手动TaskExcutor.submit()

aboutZZ avatar Jun 07 '22 01:06 aboutZZ

谢谢您的回复,我也是个初学者,所以遇到疑惑就提问了,谢谢您的答复

在 2022年6月7日,09:45,aboutZZ @.***> 写道:

 哈哈,确实,直接加注解就行了,没必要手动TaskExcutor.submit()

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

seafeee avatar Jun 07 '22 04:06 seafeee

是的,写一种即可

niefy avatar Apr 28 '23 08:04 niefy