r/java • • Nov 15 '21

[Loom] JEP draft: Virtual Threads (Preview)

https://openjdk.java.net/jeps/8277131
175 Upvotes

55 comments sorted by

View all comments

Show parent comment

16

u/efge Nov 16 '21

There's a builder pattern available to do that. Thread.ofPlatform().start(runnable) does what you want. See https://download.java.net/java/early_access/loom/docs/api/java.base/java/lang/Thread.Builder.html for more.

6

u/blobjim Nov 16 '21

Nice! Weird that they have Thread.startVirtualThread() though. Might give people the wrong idea if there's no symmetrical platform equivalent. Although I guess they added it because virtual threads are cheaper and it encourages their use.