.Thread.currentThread().getName() is "" for a virtual thread

Lutz Horn lutz.horn at posteo.de
Tue May 17 10:55:13 UTC 2022


Am 17.05.22 um 12:44 schrieb Alan Bateman:
> Unlike platform threads, virtual threads are specified to not get an 
> automatically generated name by default. The String representation has 
> the thread identifier (#96 in this case) and its state. Maybe the thread 
> identifier is enough for what you are doing?

Yes, that would be enough. So I use `Thread.currentThread().threadId()`, 
a nice addition to Java 19.

Regards

Lutz


More information about the loom-dev mailing list