Hello dear team,
I noticed, that setting spring.threads.virtual.enabled to true, will always lead to the usage of SimpleAsyncTaskExecutor, therefore ignoring the config settings affecting the pool size. Likely you chose to do that because pooling with virtual threads makes no sense, given the low overhead of virtual thread creation. Yet it's not clear enough without looking at the source code TaskExecutorConfiguration. So maybe docs could be clearer here.
The only possibility to limit the amount of parallel tasks is therefore the spring.task.execution.simple.concurrency-limit property, which essentially behaves like a max pool size. The issue I see here, is that ConcurrencyThrottleSupport, which is being used under the hood, uses the synchronized blocks which leads to thread pinning and might cause several issues with virtual threads. Maybe switching to ReentrantLock would mitigate that?
Comment From: philwebb
Thanks @peacemaker123456. We'll use this issue for the documentation updates and I've opened https://github.com/spring-projects/spring-framework/issues/32251 to see if Framework want to make changes to ConcurrencyThrottleSupport
Comment From: mhalbritter
Superseded by #39629.