记录:475 场景:在Spring Boot微服务中使用Java线程池ThreadPoolExecutor。实现Runnable接口提交线程任务到线程池。 版本:JDK 1.8,Spring Boot 2.6.3。 1.使用注解配置线程池ThreadPoolExecutor (1)说明 ThreadPoolExecutor,全称:java.util.concurrent.ThreadPoolExecutor。 使用@Bean("threadPoolExecutorHz")注解把线程池注入到Spring IOC容器中。 (2)代码 @Configuration public class ThreadPoolConfig { @Bean("threadPoolExecutorHz") public ThreadPoolExecutor threadPoolExecutor(){ ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( 8, 16, 10, TimeUnit.MILLISECONDS, new...