Java Runnable 线程接口

时间:2021-09-06 06:26:01   收藏:0   阅读:22

源码展示

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

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!