2
我一直在研究由人編寫的例子Java代碼,面對下面的代碼片段:方法引用作爲Executor實現
Runnable runnable =() -> System.out.println("Thread name: " + Thread.currentThread().getName());
Executor executor;
executor = Runnable::run;
executor.execute(runnable);
所以,我想不出在這種情況下,方法參考如何能夠實例化一個Executor,以及如果它沒有實現,怎麼可能調用execute(Runnable command)
。總體而言,在這種情況下,方法參考在窗簾後面如何工作?