spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.75k stars 38.15k forks source link

Provide first-class virtual thread option on `ThreadPoolTaskExecutor`/`ThreadPoolTaskScheduler` #33807

Closed jhoeller closed 4 weeks ago

jhoeller commented 4 weeks ago

As mentioned in #https://github.com/spring-projects/spring-framework/issues/33780#issuecomment-2442241269, there are scenarios where a ThreadPoolTaskExecutor or ThreadPoolTaskScheduler benefits from being configured with a factory for virtual threads. In contrast to SimpleAsyncTaskExecutor/SimpleAsyncTaskScheduler, this is naturally integrated with Spring's lifecycle management for stopping and restarting execution threads, including an early stop signal for a graceful shutdown arrangement. For 6.2, we can provide first-class virtual thread support through a setVirtualThreads(true) flag on ThreadPoolTaskExecutor and ThreadPoolTaskScheduler.