This document is to use multi-threading to open a single thread to do some things in the business (such as sending emails), in order to achieve the purpose of improving the running speed of the overall project
Main start class
First use @EnableAsync to enable Springboot's support for asynchronous tasks
@EnableAsync
public class TzsbxtApplication extends SpringBootServletInitializer {
Configuration class
The configuration class implements the interface AsyncConfigurator and returns a ThreadPoolTaskExecutor thread pool object.
The @Async annotation indicates that the method is an asynchronous method. If the annotation is on a class, it indicates that all methods in this class are asynchronous.
@Async
public void executeAsyncMail(String body) {
System.out.println("写执行内容");
}