How do I create a real virtual thread pool?
Jianbin Chen
jianbin at apache.org
Fri Sep 26 14:17:55 UTC 2025
Hi Alan,
Thanks for your reply. I haven’t implemented this yet; it was just an idea
I raised for discussion.
Thanks for pointing me to the CustomSchedulers feature — I think it could
help isolate platform threads in a multi‑tenant environment while still
letting us benefit from virtual threads.
I’ll give it a try. Thanks again. By the way, do you know whether this
feature is already available in JDK 25?
Best Regards.
Jianbin Chen, github-id: funky-eyes
Alan Bateman <alan.bateman at oracle.com> 于 2025年9月26日周五 18:44写道:
>
>
> On 26/09/2025 10:36, Jianbin Chen wrote:
> > Hi everyone,
> >
> > I hope you’re doing well. I have a question about a multi-tenant
> > scenario. I want to create a dedicated thread pool for each tenant,
> > and these pools will perform a lot of I/O (for example, database reads
> > and writes). For this reason I’d like to use virtual threads. However,
> > because virtual threads share platform threads under the hood, they
> > cannot be fully isolated from one another.
> >
> Can you say a bit more about the multi-tenancy implementation? Is this a
> fork of the JDK with deep changes to isolate tenants, or is this
> isolation built with module layers or class loaders? If the latter then
> I assume it's an issue for the FJP common pool and all other system-wide
> resources.
>
> So while the JDK doesn't have any support for tenancies, there is
> prototype/experimental support for custom schedulers in the loom repo
> [1]. That could be used to experiment with a having a virtual thread
> scheduler per tenant, or using a system-wide scheduler that dispatches
> the tasks for virtual threads in a tenant to the carriers in that
> tenant. It could be fun to work on. If you do explore this area then
> please come back with any results.
>
> -Alan
>
> [1]
> https://github.com/openjdk/loom/blob/fibers/loom-docs/CustomSchedulers.md
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20250926/dbb614bf/attachment.htm>
More information about the loom-dev
mailing list