什么也不返回的函数式接口 [英] functional interface that takes nothing and returns nothing
本文介绍了什么也不返回的函数式接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
JDK 中是否有一个标准的函数式接口,它什么也不带,什么也不返回?我找不到一个.类似于以下内容:
Is there a standard functional interface in the JDK that takes nothing and returns nothing? I cannot find one. Something like the following:
@FunctionalInterface
interface Action {
void execute();
}
推荐答案
Runnable 怎么样:
How about Runnable :
@FunctionalInterface
public interface Runnable {
/**
* When an object implementing interface <code>Runnable</code> is used
* to create a thread, starting the thread causes the object's
* <code>run</code> method to be called in that separately executing
* thread.
* <p>
* The general contract of the method <code>run</code> is that it may
* take any action whatsoever.
*
* @see java.lang.Thread#run()
*/
public abstract void run();
}
这篇关于什么也不返回的函数式接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文