功能界面,什么都不带,什么都不返回

时间:2014-05-30 16:03:52

标签: java function java-8

JDK中是否有标准的功能接口,什么都不带,什么都不返回?我找不到一个。如下所示:

@FunctionalInterface
interface Action {
  void execute();
}

1 个答案:

答案 0 :(得分:144)

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();
}