默认情况下,当指定
@Async上的方法,将要使用的执行程序是如所描述的提供给“注解驱动”元素的一个这里。
但是,
@Async当需要指示在执行给定方法时应使用默认值以外的执行器时,可以使用注释的value属性。
@Async("otherExecutor")void doSomething(String s) { // this will be executed asynchronously by "otherExecutor"}在这种情况下,“ otherExecutor”可以是Spring容器中任何Executor
bean的名称,也可以是与任何Executor关联的限定符的名称,例如,用元素或Spring的
@Qualifier注释指定的名称。
https://docs.spring.io/spring/docs/current/spring-framework-
reference/html/scheduling.html
可能您需要使用所需的池设置在应用程序中指定otherExecutor bean。
@Beanpublic TaskExecutor otherExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(5); executor.setMaxPoolSize(10); executor.setQueueCapacity(25); return executor;}


