Suppose this:
ExecutorService service = ...;
// somewhere in the code the executorService is used this way:
service.submit(() -> { ... });
The lambda expression would default to Callable
.
Is there a way to make it instantiate a Runnable
instead?
Thanks for your help.
You can declare it as a Runnable, or use a cast:
Runnable r = () -> { ... };
executorService.submit(r);
or
executorService.submit((Runnable) () -> { ... });