package com.lxxu.testthread;
class MyThread3 implements Runnable{//线程的主体类
private String title;
public MyThread3(String title){
this.title = title;
}
@Override
public void run(){//线程的主体方法
for(int i = 0; i < 10; i++){
System.out.println(this.title+"运行,i="+i);
}
}
}
public class ThreadDemo3{
public static void main(String[] args)
{
for(int x=0;x<3;x++){
String title = "线程对象 " + x;
/*Runnable run = ()->{
for(int y=0;y<10;y++){
System.out.println(title+"运行,y="+y);
}
};*/
new Thread(()->{
for(int y=0;y<10;y++){
System.out.println(title+"运行,y="+y);
}
}).start();
}
}
}
多线程引用Lameda函数表达式
猜你喜欢
转载自blog.csdn.net/qq_42740745/article/details/84559942
今日推荐
周排行