<div dir="ltr">Good afternoon, everyone! I think I've found a bug. There is a code that basically pings the server. I decided to test it on virtual threads and for some reason they don't work in it.<br>Code:<br>```<br>    public static void main(String[] args) throws ExecutionException, InterruptedException {<br>        System.out.println("Test fixed thread poll");<br>        long start = System.currentTimeMillis();<br>        var counter = ping(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()));<br>        System.out.println("Execute time " + (System.currentTimeMillis() - start) + " " + counter);<br><br>        System.out.println("half-time break");<br>        LockSupport.parkNanos(10000000000L);<br><br>        System.out.println("Test virtual thread poll");<br>        start = System.currentTimeMillis();<br>        counter = ping(Executors.newVirtualThreadPerTaskExecutor());<br>        System.out.println("Execute time " + (System.currentTimeMillis() - start) + " " + counter);<br><br><br>    }<br><br>    private static int ping(ExecutorService executor) throws ExecutionException, InterruptedException {<br>        AtomicInteger counter = new AtomicInteger();<br>        var futures = Stream.<CompletableFuture<Void>> builder();<br>        for (int i = 0; i < 1000; i++) {<br>            var fut = CompletableFuture.runAsync(() -> {<br>                try {<br>                    InetAddress address = InetAddress.getByName("8.8.8.8");<br>                    boolean reachable = address.isReachable(100);<br>                    counter.incrementAndGet();<br>                } catch (Throwable e) {<br>                    e.printStackTrace();<br>                }<br>            }, executor);<br>            futures.add(fut);<br>        }<br>        CompletableFuture.allOf(futures.build().toArray(CompletableFuture[]::new)).get();<br>        return counter.get();<br>    }<br><br>```<br>I get the following results. (-Djdk.tracePinnedThreads=full is enabled and it outputs nothing to the console)<br>Test fixed thread poll:<br>Execute time 6317 1000<br>Test virtual thread poll:<br>Execute time 6319 1000<br><br>I expected to get results like this. (You can get such results if you replace the request to the network with Thread.sleep(100))<br>Test fixed thread poll:<br>Execute time 6308 1000<br>Test virtual thread poll:<br>Execute time 110 1000<br><br><br>openjdk 22.0.2 2024-07-16<br>OpenJDK Runtime Environment GraalVM CE 22.0.2+9.1 (build 22.0.2+9-jvmci-b01)<br>OpenJDK 64-Bit Server VM GraalVM CE 22.0.2+9.1 (build 22.0.2+9-jvmci-b01, mixed mode, sharing)<div class="gmail-yj6qo"></div><div class="gmail-adL"><br></div></div>