try (var executor = Executors
.newVirtualThreadPerTaskExecutor()) {
IntStream
.range(0, 1_000_000)
.forEach(number -> {
executor.submit(() -> {
Thread.sleep(Duration.ofSeconds(1));
return number;
});
});
} // executor.close() is called implicitly, and waits