I'm working on a project where the following line is used to create a test Executor member variable instance:
private Executor executor = Runnable::run;
The code runs and compiles but I don't understand how Runnable::run creates an instance of Executor since both are different interfaces.
Is anyone able to explain? In particular:
- Where does the implementation of Runnable come from?
- How is it assigned to an
Executorimplementation (sinceExecutoris a different interface)? - What kind of
Executoris created? e.g. single threaded or pooled - How would this be written before Java 8?
Thanks.