@Configuration
@EnableAsync
@Slf4j
public class ExecutorConfig {
@Bean("taskExecutor")
public ThreadPoolTaskExecutor asyncServiceExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
return executor;
}
}
// test code
var executor = executorConfig.asyncServiceExecutor();
System.err.println(System.identityHashCode(executor));
System.err.println(executor);
System.err.println(System.identityHashCode(executor));
System.err.println(executor);
// output
2016053161
org.springframework.cloud.sleuth.instrument.async.LazyTraceThreadPoolTaskExecutor@62730eda
2016053161
org.springframework.cloud.sleuth.instrument.async.LazyTraceThreadPoolTaskExecutor@65d849e0