Good morning,
Is it possible to make spring-boot create thread when needed and also kill it?
Good morning,
Is it possible to make spring-boot create thread when needed and also kill it?
Make a note of @EnableAsync
in your Application.java
and give extends
in class AsyncConfigurerSupport
.
With this it will be possible to create a ThreadPoolTaskExecutor
, follow the example below.
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(2);
executor.setMaxPoolSize(2);
executor.setQueueCapacity(500);
executor.setThreadNamePrefix("GithubLookup-");
executor.initialize();
return executor;
}
Follow the Spring Boot's own guide link: link