<div dir="ltr">That is not unique to Executors.newVirtualThreadPerTaskExecutor. It is also the same Executors.newThreadPerTaskExecutor. Both use the same ThreadPerTaskExecutor (with different thread factories) that returns instances of ThreadBoundFuture, which extends CompletableFuture [1], for calls to the submit(..) methods.<div><br></div><div>I don't think that is "leaking" in the way a leak is typically considered (i.e. a memory leak). It may be "leaking" some information about the implementation, but that is just a consequence of an open, inspectable system like the JDK.</div><div><br></div><div>[1]: <a href="https://github.com/openjdk/loom/blob/fibers/src/java.base/share/classes/java/util/concurrent/ThreadPerTaskExecutor.java#L327">https://github.com/openjdk/loom/blob/fibers/src/java.base/share/classes/java/util/concurrent/ThreadPerTaskExecutor.java#L327</a></div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div><br></div>-Paul</div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 14, 2023 at 3:41 PM Kasper Nielsen <<a href="mailto:kasperni@gmail.com">kasperni@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I don't know if it is much of an issue in practice but you can cast the<br>
futures returned from Executors.newVirtualThreadPerTaskExecutor<br>
to CompletableFuture:<br>
<br>
ExecutorService e = Executors.newVirtualThreadPerTaskExecutor();<br>
CompletableFuture f = (CompletableFuture<?>) e.submit(() -> {});<br>
<br>
Other executors return instances of FutureTask which is probably less<br>
likely to be abused.<br>
<br>
/Kasper<br>
</blockquote></div>