<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Sorry, I reread the virtual thread JEP and found that I can use `Thread.Builder::unstarted`</div><div dir="ltr">to create virtual threads that have not been started, and then I can do what I want to do.</div><div dir="ltr"><br></div><div dir="ltr">Sorry for wasting your time.<br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr">Glavo</div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 27, 2023 at 2:40 AM Alan Bateman <<a href="mailto:Alan.Bateman@oracle.com">Alan.Bateman@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">On 26/07/2023 18:44, Glavo wrote:<br>
> Sorry I didn't understand `Thread.Builder` correctly.<br>
><br>
> Still, I'd be happier if we could provide the convenience method above.<br>
><br>
> I'm just developing a library and want to get an ExecutorService that <br>
> names the virtual threads with my strategy.<br>
> Achieving this was a bit of a pain, especially since I had to use <br>
> reflection to call the thread builder API for Java 8 compatibility.<br>
> I'd like to have a simple factory method instead of using the thread <br>
> builder API unnecessarily.<br>
><br>
It sounds like you are looking for:<br>
<br>
ThreadFactory factory = Thread.ofVirtual().name("duke-", 0).factory();<br>
var executor = Executors.newThreadPerTaskExecutor(factory);<br>
<br>
which will name the threads duke-0, duke-1, duke-2, ...  I don't think a <br>
strong case for introducing a new factory method here, the issue sounds <br>
more like it's more code using core reflection.<br>
<br>
-Alan<br>
</blockquote></div>