Skip to content

Why is there an option to enable virtual threads in ThreadPoolTaskExecutor? #34758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
peter-cheon opened this issue Apr 15, 2025 · 1 comment
Closed
Labels
for: stackoverflow A question that's better suited to stackoverflow.com status: invalid An issue that we don't feel is valid

Comments

@peter-cheon
Copy link

Hello,
From what I understand, virtual threads are structurally designed in a way that doesn't require a thread pool.
However, despite this, ThreadPoolTaskExecutor has added an option to enable virtual threads.

I had assumed that when virtual threads are enabled, settings like core pool size, max pool size, and queue capacity wouldn't be used.
But it seems that even when virtual threads are enabled, those configurations are still being utilized in some way.
Looking into the code, it appears that a virtual thread can be injected into the ThreadFactory of Java’s ThreadPoolExecutor.

I'm curious about the intention behind this. Was it designed to allow virtual threads to be used like a thread pool?

Thank you.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 15, 2025
@bclozel
Copy link
Member

bclozel commented Apr 15, 2025

Those options have been introduced in #33807
You'll find the rationale behind this change in #33780 (comment). In a nutshell, it is not idiomatic nor advised to pool virtual threads, but in some cases a more involved coordination and lifecycle management is required.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Apr 15, 2025
@bclozel bclozel added status: invalid An issue that we don't feel is valid for: stackoverflow A question that's better suited to stackoverflow.com and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: stackoverflow A question that's better suited to stackoverflow.com status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants