Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java 8 lambda ambiguous runnable and callback [duplicate]

Tags:

java

java-8

Executors.newFixedThreadPool(3).submit(() -> {doSmth();});

"Ambiguous method call. Both submit (Callable) in ExecutorService and submit (Runnable) in ExecutorService match."

How to fix it? I know that I can use anonymous class but I'd like to use Function.

like image 607
Eugene To Avatar asked Dec 05 '22 05:12

Eugene To


1 Answers

Executors.newFixedThreadPool(3).submit(() -> 1); //Callable
Executors.newFixedThreadPool(3).submit(() -> {doSmth();}); //Runnable
like image 96
Sergey Morozov Avatar answered Jan 18 '23 23:01

Sergey Morozov