Thread.ofVirtual() starts a virtual thread without an executor.
Thread t = Thread.ofVirtual().start(() ->
System.out.println("hello from " + Thread.currentThread().isVirtual()));
t.join();
hello from true
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-07-26