首页 > 编程语言 > 详细

Java Runnable 线程接口

时间:2021-09-06 06:26:01      阅读:16      评论:0      收藏:0      [点我收藏+]

源码展示

package java.lang;

/**
 * The Runnable interface should be implemented by any
 * class whose instances are intended to be executed by a thread. 
 */
@FunctionalInterface
public interface Runnable {
    /**
     * When an object implementing interface Runnable is used
     * to create a thread, starting the thread causes the object‘s
     * run() method to be called in that separately executing thread.
     */
    public abstract void run();
}

示例

public class Test {
    public static void main(String args[]) {
        new Thread(()->{
            System.out.println("Runnable 的 lambda 写法!");
        }).start();
    }
}

Java Runnable 线程接口

原文:https://www.cnblogs.com/feiqiangsheng/p/15225928.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!