多线程获取名字和设置名字。

public class Demo02 {
public static void main(String[] args) {
第一种方法:
new Thread("构造方法设置线程名字"){
public void run(){
System.out.println(this.getName()+".........bbbbbbb");
}
}.start();
new Thread(){
public void run(){
this.setName("通过setName设置线程名字"); 第二种方法
System.out.println(this.getName()+".........aaaaaa");
}
}.start();
}
}
posted @ 2020-07-20 21:03  一块  阅读(730)  评论(0编辑  收藏  举报