-1
Good morning earthlings,
There is the possibility to make spring-boot create thread when needed and also kill the same ?
-1
Good morning earthlings,
There is the possibility to make spring-boot create thread when needed and also kill the same ?
0
Enter the annotation @EnableAsync
in his Application.java
and give a extends
in class AsyncConfigurerSupport
.
With this it will be possible to create a ThreadPoolTaskExecutor
, following 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 link from the Spring Boot guide itself: https://spring.io/guides/gs/async-method/
Browser other questions tagged java spring-boot
You are not signed in. Login or sign up in order to post.
What would be the scenario?
– Leonardo Villela