何も受け取らず何も返さない関数型インターフェース [重複] 質問する

何も受け取らず何も返さない関数型インターフェース [重複] 質問する

JDK には、何も受け取らず、何も返さない標準的な関数インターフェースがありますか? 見つかりません。次のようなものです:

@FunctionalInterface
interface Action {
  void execute();
}

ベストアンサー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();
}

おすすめ記事