<div dir="auto"><div dir="auto"><div dir="auto"><div dir="auto">Hi Alan,</div><div dir="auto"><br></div><div dir="auto">Thanks for your reply. I haven’t implemented this yet; it was just an idea I raised for discussion.</div><div dir="auto"><br></div><div dir="auto">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.</div><div dir="auto"><br></div><div dir="auto">I’ll give it a try. Thanks again. By the way, do you know whether this feature is already available in JDK 25?<br><br><div data-smartmail="gmail_signature" dir="auto">Best Regards.<br>Jianbin Chen, github-id: funky-eyes </div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Alan Bateman <<a href="mailto:alan.bateman@oracle.com" target="_blank" rel="noreferrer">alan.bateman@oracle.com</a>> 于 2025年9月26日周五 18:44写道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On 26/09/2025 10:36, Jianbin Chen wrote:<br>
> Hi everyone,<br>
><br>
> I hope you’re doing well. I have a question about a multi-tenant <br>
> scenario. I want to create a dedicated thread pool for each tenant, <br>
> and these pools will perform a lot of I/O (for example, database reads <br>
> and writes). For this reason I’d like to use virtual threads. However, <br>
> because virtual threads share platform threads under the hood, they <br>
> cannot be fully isolated from one another.<br>
><br>
Can you say a bit more about the multi-tenancy implementation? Is this a <br>
fork of the JDK with deep changes to isolate tenants, or is this <br>
isolation built with module layers or class loaders? If the latter then <br>
I assume it's an issue for the FJP common pool and all other system-wide <br>
resources.<br>
<br>
So while the JDK doesn't have any support for tenancies, there is <br>
prototype/experimental support for custom schedulers in the loom repo <br>
[1]. That could be used to experiment with a having a virtual thread <br>
scheduler per tenant, or using a system-wide scheduler that dispatches <br>
the tasks for virtual threads in a tenant to the carriers in that <br>
tenant. It could be fun to work on. If you do explore this area then <br>
please come back with any results.<br>
<br>
-Alan<br>
<br>
[1] <br>
<a href="https://github.com/openjdk/loom/blob/fibers/loom-docs/CustomSchedulers.md" rel="noreferrer noreferrer noreferrer" target="_blank">https://github.com/openjdk/loom/blob/fibers/loom-docs/CustomSchedulers.md</a><br>
</blockquote></div></div>