Introduce SimpleAsyncTaskScheduler
with virtual threads support (as an alternative to ThreadPoolTaskScheduler
)
#30956
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Following up on the 6.1 M1 virtual threads support (#30241) and the 6.1 M2 executor/scheduler revision (#30831, #27090, #24497), we are going to introduce a
SimpleAsyncTaskScheduler
in 6.1 M4. This is an extension ofSimpleAsyncTaskExecutor
which inherits thesetVirtualThreads(true)
capability (and also its configurable concurrency limit) and - when configured that way - uses a single virtual thread for scheduling and and a separate individual virtual thread per scheduled task execution. This is effectively a@Scheduled @Async
like execution model but baked into a scheduler implementation, avoiding any pool setup and adhering to the general thread-per-task model of virtual threads.As a side effect, a
SimpleAsyncTaskScheduler
can serve as a fully capable replacement for aSimpleAsyncTaskExecutor
, e.g. as a single shared instance serving as aTaskExecutor
as well as aTaskScheduler
. This is generally not the case with other executor/scheduler implementations which tend to have specific constraints for the scheduler thread pool, requiring a separate thread pool for general executor purposes in practice: compare e.g.ThreadPoolTaskExecutor
versus ThreadPoolTaskScheduler`.As an alternative to the built-in thread-per-task capability,
SimpleAsyncTaskScheduler
can also be configured with a separate target executor for scheduled task execution throughsetTargetTaskExecutor
: e.g. pointing to a sharedThreadPoolTaskExecutor
bean. This is still rather different from aThreadPoolTaskScheduler
setup since it always uses a single scheduler thread while dynamically dispatching to the target thread pool which may have a dynamic core/max pool size range, participating in a shared concurrency limit (for explicitly submitted tasks as well as scheduled tasks, all bound by the same executor max pool size).The text was updated successfully, but these errors were encountered: