Start named virtual thread

Glavo zjx001202 at gmail.com
Wed Jul 26 17:44:47 UTC 2023


Sorry I didn't understand `Thread.Builder` correctly.

Still, I'd be happier if we could provide the convenience method above.

I'm just developing a library and want to get an ExecutorService that names
the virtual threads with my strategy.
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.
I'd like to have a simple factory method instead of using the thread
builder API unnecessarily.

Glavo


On Thu, Jul 27, 2023 at 12:59 AM Alan Bateman <Alan.Bateman at oracle.com>
wrote:

> On 26/07/2023 17:46, Glavo wrote:
>
> Hi,
>
> There are times when I'm not happy with
> `Thread.ofVirtual().name(xxx).factory()` and would like more flexibility in
> naming virtual threads.
> Therefore, I would like to have an API method like this:
>
> public static Thread startVirtualThread(Runnable task, String name)
>
>
> Can we provide such an API method?
>
>
>
> 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.
>
> -Alan
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230727/7d9d5a90/attachment-0001.htm>


More information about the loom-dev mailing list