...
try (ExecutorService executor = Executors.newUnboundedVirtualThreadExecutor()) {
Callable<String> task1 = () -> "foo";
Callable<String> task2 = () -> "bar";
String result = executor.invokeAny(List.of(task1, task2));
}
Appendix: Differences between regular Threads and virtual Threads
...
Overview
Content Tools
ThemeBuilder