Spring boot uses @ async asynchronous call: detailed explanation of elegant shutdown of threadpooltaskscheduler thread pool

preface

Previously, I shared an article about using @ async to implement asynchronous tasks and thread pool control in spring boot: "spring boot uses @ async to implement asynchronous calls: Customizing thread pool". Recently, many problems caused by incorrect processing of many asynchronous tasks have been found. Therefore, this article continues with the previous content and continues to talk about the elegant shutdown of thread pool, mainly for the thread pool of threadpooltaskscheduler.

In the example chapter4-1-3 in the previous article, we defined a thread pool, then wrote three tasks using the @ async annotation, and specified the thread pool used for the execution of these tasks. In the unit test above, we didn't specifically talk about the problems related to shutdown. Let's simulate a problem scene.

Github: https://github.com/dyc87112/SpringBoot-Learning/

Gitee: https://gitee.com/didispace/SpringBoot-Learning/

Local download: http://xiazai.jb51.net/201805/yuanma/SpringBoot-Learning (jb51.net). rar

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>