public class TestGetThread extends Thread {
TestGetThread(String s){
super(s);
}
public void run() {
System.out.println(this.getName());
}
public static void main(String args[]) {
System.out.println(Thread.currentThread().getName());
TestGetThread thread1 = new TestGetThread("线程1"):
TestGetThread thread2 = new TestGetThread("线程2");
thread1.start();
thread2.start();
}
}
程序运行的结果:
(1)_______
(2)______
(3)____________
main
线程1
线程2
谢谢!