/* 
join: 
当A线程遇到了B线程的join()方法时,A就会等待,等到B线程执行完,A才会执行。 
 
join可以用来临时加入线程执行。 
 
*/ 
 
class Dem implements Runnable 
{ 
        public void run() 
        { 
                for(int x = 0;x<70;x++) 
                { 
                        System.out.prtintln("你好明天"); 
                } 
        } 
} 
class Jon 
{ 
        public static void main(String[] args) 
        { 
                Dem d = new Dem(); 
                Thread t1 = new Thread(); 
                Thread t2 = new Thread(); 
                t1.start(); 
                t2.start(); 
                t1.join(); 
                System.out.println("线程加入"); 
        } 
} |