package demo5;
public class TestA {
public static void main(String[] args) {
// TODO Auto-generated method stub
for (int i = 0; i <10; i++) {
if (i==5) {
A a = new A("name");
try {
a.start();
a.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
System.out.println(Thread.currentThread().getName()+i);
}
}
}
package demo5;
public class A extends Thread{
public A(String name) {
super(name);
// TODO Auto-generated constructor stub
}
@Override
public void run() {
// TODO Auto-generated method stub
for (int i = 0; i <5; i++) {
System.out.println(Thread.currentThread().getName()+i);
}
}
}
main0
main1
main2
main3
main4
name0
name1
name2
name3
name4
main5
main6
main7
main8
main9