<div dir="ltr"><div dir="ltr"></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Em sex., 11 de ago. de 2023 às 15:26, Attila Kelemen <<a href="mailto:attila.kelemen85@gmail.com">attila.kelemen85@gmail.com</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">To elaborate more, your executor can be created for any type, but that is almost pointless for an executor, because an executor instance has to support all types. Similarly you can't create a simplified `ExecutorService` as `Function<Callable<T>, Future<T>>`. Such an executor would be very limited in usefulness, because to simply put: An executor cannot have a type argument.</div></blockquote><div><br></div><div>The following compiles just fine. </div></div><div><br></div><div><span style="font-family:monospace">import java.util.function.Function;</span><br></div><div><font face="monospace">import java.util.function.Supplier;<br><br>interface Executor {<br>    default <T> T run(Supplier<T> s, Function<Supplier<T>, Supplier<T>> mapper) {<br>        return mapper.apply(s).get();<br>    }<br>}<br><br>class Wrap {<br>    public static void main(String[] args) {<br>        Executor z = new Executor() {};<br>        String x = z.run(() -> "hi", Wrap::withMessage);<br>        System.out.println(x);<br>    }<br><br>    static <T> Supplier<T> withMessage(Supplier<T> s) {<br>        return () -> {<br>            System.out.println("before");<br>            try {<br>                return s.get();<br>            } finally {<br>                System.out.println("after");<br>            }<br>        };<br>    }<br>}</font><br></div><div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Pedro Lamarão</div></div></div></div></div>