功能接口,不需要任何东西,也不会返回 [英] functional interface that takes nothing and returns nothing

查看:130
本文介绍了功能接口,不需要任何东西,也不会返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆