package cn.tt9;
/*获取线程名称
public final String getName()
设置线程名称:1 setName(); 2通过构造方法
获取main方法所在的线程名称
public static Thread currentThread():返回当前正在执行的线程对象 静态,返回Thread
*/
public class Test01 {
public static void main(String[] args) {
Mythread my1=new Mythread();
Mythread my2=new Mythread();
System.out.println(Thread.currentThread().getName());//获取当前进程的名称
my1.setName("hello");
my2.setName("收集");
Mythread my3=new Mythread("haha");
my3.start();
my1.start();
my2.start();
}
}
|
|