小编典典

不带任何内容且不返回任何内容的功能接口

java

JDK中是否有一个标准的功能接口,该接口什么都不做,什么也不返回?我找不到一个。类似于以下内容:

@FunctionalInterface
interface Action {
  void execute();
}

阅读 172

收藏
2020-09-08

共1个答案

小编典典

那么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();
}
2020-09-08