Java 什么也不返回的函数式接口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23958814/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 09:25:05 来源:igfitidea点击:
functional interface that takes nothing and returns nothing
提问by deamon
Is there a standard functional interface in the JDK that takes nothing and returns nothing? I cannot find one. Something like the following:
JDK 中是否有一个标准的函数式接口,它什么都不带,什么都不返回?我找不到一个。类似于以下内容:
@FunctionalInterface
interface Action {
void execute();
}
采纳答案by Eran
How about Runnable :
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();
}