<div dir="ltr">Thanks for the quick clarification!<div><br></div><div>Good to know that is on the roadmap. </div><div><br></div><div>I intend to make use of this for building a DSL where a user can</div><div>a) update the mutable variables without having to think about concurrency (because of single carrier thread)</div><div>b) freely use blocking (because of virtual threads within that carrier thread)</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 18, 2022 at 2:35 PM Ron Pressler <<a href="mailto:ron.pressler@oracle.com">ron.pressler@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div style="overflow-wrap: break-word;">
<div>Hi.</div>
<div><br>
</div>
Custom schedulers were not delivered as part of JEP 425, as they are not yet ready for release.
<div>We intend to add that feature at a later date. Until then, only the default scheduler can schedule virtual threads.</div>
<div><br>
</div>
<div>— Ron<br>
<div><br>
<blockquote type="cite">
<div>On 18 Jul 2022, at 08:50, Mushtaq Ahmed <<a href="mailto:mushtaq.a@gmail.com" target="_blank">mushtaq.a@gmail.com</a>> wrote:</div>
<br>
<div>
<div dir="ltr">Google search for a similar use case led me to this discussion.
<div><br>
</div>
<div>It seems that API has changed in the latest builds. </div>
<div><br>
</div>
<div>What is the current way to achieve the following?</div>
<div>
<pre style="white-space:pre-wrap">Thread.builder().virtual(Executors.newSingleThreadExecutor()).factory()</pre>
<div>Thanks,</div>
<div>Mushtaq</div>
<div><br>
</div>
<div>-----------------------------------------------------</div>
<div>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"><pre style="white-space:pre-wrap">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"><br></pre>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>

</blockquote></div>