<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 didn't understand `Thread.Builder` correctly.<br></div><div dir="ltr"><br></div><div dir="ltr">Still, I'd be happier if we could provide the convenience method above.<br></div><div dir="ltr"><br></div><div dir="ltr">I'm just developing a library and want to get an ExecutorService that names the virtual threads with my strategy.</div><div dir="ltr">Achieving this was a bit of a pain, especially since I had to use reflection to call the thread builder API for Java 8 compatibility.<br></div><div dir="ltr">I'd like to have a simple factory method instead of using the thread builder API unnecessarily.<br></div><div dir="ltr"><br></div><div>Glavo</div><div dir="ltr"><br></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 12:59 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">
<div>
On 26/07/2023 17:46, Glavo wrote:<br>
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">Hi,
<div><br>
</div>
<div>There are times when I'm not happy with
`Thread.ofVirtual().name(xxx).factory()` and would
like more flexibility in naming virtual threads.<br>
</div>
<div>Therefore, I would like to have an API method
like this:<br>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div>public static Thread
startVirtualThread(Runnable task, String name)</div>
</div>
</div>
</div>
</blockquote>
<br>
<div>Can we provide such an API method?<br>
</div>
<br>
</div>
</div>
</div>
</blockquote>
<br>
<br>
It's easy to start a virtual thread with a name if you really want,
e.g. Thread.ofVirtual().name("duke").start(task);, so I'm curious
what problem or issue you are running into.<br>
<br>
-Alan<br>
<br>
<br>
<br>
</div>
</blockquote></div>