class Demo implements Runnable
{
public void run()
{
for(int x = 0;x<70;x++)
{
System.out.println(Thread.currentThread().getName()+”……”+x);
}
}
}
class JoinDemo
{
public static void main(String[] args)
{
Demo d = new Demo();
Thread t1 = new Thread(d);
Thread t2 = new Thread(d);
t1.start();
t1.join();
t2.start();
for(int x=0;x<80;x++)
{
System.out.println(“main…..”+x);
}
System.out.println(“over”);
}
}
这个程序里t1和t2是子线程,那么主线程呢,是不是控制for循环的那个线程? |
|