<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class="">Hi.</div>
<div class=""><br class="">
</div>
Custom schedulers were not delivered as part of JEP 425, as they are not yet ready for release.
<div class="">We intend to add that feature at a later date. Until then, only the default scheduler can schedule virtual threads.</div>
<div class=""><br class="">
</div>
<div class="">— Ron<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 18 Jul 2022, at 08:50, Mushtaq Ahmed <<a href="mailto:mushtaq.a@gmail.com" class="">mushtaq.a@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Google search for a similar use case led me to this discussion.
<div class=""><br class="">
</div>
<div class="">It seems that API has changed in the latest builds. </div>
<div class=""><br class="">
</div>
<div class="">What is the current way to achieve the following?</div>
<div class="">
<pre style="white-space: pre-wrap;" class="">Thread.builder().virtual(Executors.newSingleThreadExecutor()).factory()</pre>
<div class="">Thanks,</div>
<div class="">Mushtaq</div>
<div class=""><br class="">
</div>
<div class="">-----------------------------------------------------</div>
<div class="">Reference to the original thread (in case this email shows up outside the original thread, not sure how mailman works):</div>
<pre style="white-space: pre-wrap;" class=""><pre style="white-space:pre-wrap" class="">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:</pre>    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</pre>
<pre style="white-space: pre-wrap;" class=""><br class=""></pre>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>