class MyThread extends Thread{
public MyThread(String name) {
super(name);
}
public void run(){
for(int x=0;x<1000;x++){
System.out.println((this.currentThread()==this)+"+++"+this.getName()+"---"+x);
}
}
}
public class YiChang {
public static void main(String[] args) throws InterruptedException {
MyThread myThread=new MyThread("One");
myThread.setName("One1");
myThread.start();
for(int x=0;x<1000;x++){
System.out.println("main---"+x);
}
}
} |
|