- Loading...
...
The Thread.Builder API can also be used to create virtual threads that are configured at build time. The first snippet below creates an un-started thread. The second example creates second snippet creates and starts a thread with thread name "bob".
| Code Block | ||
|---|---|---|
| ||
Thread thread1 = Thread.builder().virtual().task(() -> System.out.println("Hello")).build();
Thread thread2 = Thread.builder()
.virtual()
.name("bob")
.task(() -> System.out.println("I'm Bob!"))
.start(); |
...