single thread executor

Mushtaq Ahmed mushtaq.a at gmail.com
Mon Jul 18 07:50:51 UTC 2022


Google search for a similar use case led me to this discussion.

It seems that API has changed in the latest builds.

What is the current way to achieve the following?

Thread.builder().virtual(Executors.newSingleThreadExecutor()).factory()

Thanks,
Mushtaq

-----------------------------------------------------
Reference to the original thread (in case this email shows up outside the
original thread, not sure how mailman works):

Remember, you want multiple virtual threads, but use only on platform
thread to schedule them. So you need to pass the single-thread executor
as the virtual thread scheduler:

    ThreadFactory tf =
Thread.builder().virtual(Executors.newSingleThreadExecutor()).factory();
And then you can use the thread factory directly to create virtual threads,
or use it like so:     ExecutorService e =
Executors.newUnboundedExecutor(tf); - Ron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20220718/b05663e2/attachment.htm>


More information about the loom-dev mailing list