public class MyThread extends Thread{
@Override
public void run(){
for(int i=0;i<10000;i++){
System.out.println("i="+i+" "+"run="+Thread.currentThread().getName());
}
}
}
import mythread.MyThread;
public class Test {
public static void main(String[] args) {
MyThread thread=new MyThread();
thread.setName("myThread");
thread.start();
for(int i=0;i<10000;i++){
System.out.println("i="+i+" "+"main="+Thread.currentThread().getName());
}
}
}