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