您需要将Task Executors,Queues等注入常规bean。然后在运行时将参数设置为它们。例如
<task:executor id="messageTaskExecutor" pool-size="10" queue-capacity="10" keep-alive="1" rejection-policy="CALLER_RUNS"/>
将生产类型的豆 ThreadPoolExecutor 有名字 messageTaskExecutor 。因此,它可能会注入:
ThreadPoolExecutor
messageTaskExecutor
@Autowired @Qualifier("messageTaskExecutor") // or @Inject @Named("messageTaskExecutor") ThreadPoolExecutor messageTaskExecutor;
你可以打电话之后 messageTaskExecutor.setMaximumPoolSize