首页 > 其他 > 详细

函数式接口作为参数

时间:2020-07-10 17:22:42      阅读:139      评论:0      收藏:0      [点我收藏+]
 1 /**
 2  * @author jliu.l
 3  * @2020年7月10日
 4  * 
 5  */
 6 public class Demo01Runnable {
 7     
 8     public static void startThread(Runnable run) {
 9         new Thread(run).start();
10     }
11 
12     public static void main(String[] args) {
13         startThread(new Runnable() {
14             
15             @Override
16             public void run() {
17                 System.out.println(Thread.currentThread().getName()+"-->"+"线程开启");
18                 
19             }
20         });
21         
22         startThread(()->{
23             System.out.println(Thread.currentThread().getName()+"-->"+"线程开启");
24         });
25         
26         startThread(()->
27             System.out.println(Thread.currentThread().getName()+"-->"+"线程开启")
28         );
29     }
30 
31 }

 

函数式接口作为参数

原文:https://www.cnblogs.com/jliu-l/p/13280000.html

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