日期:2014-05-20  浏览次数:20705 次

高分!!!小菜鸟求助关于多线程问题!!!!
package fuck1;
public class root30 {
   public static void main(String[] args) {
        xiancheng a = new xiancheng();
        xiancheng1 b = new xiancheng1();
        xiancheng2 c = new xiancheng2();
        b.mt=a;
        a.start();
        b.start();
        c.start();
    }
}
class xiancheng extends Thread
{
    public void run()
    {
       for (int i=0;i<20;i++)   
       {    
           System.out.print("▲");
           try {
                thread.sleep(1000);
            } catch (InterruptedException ie) {
                // TODO: Add catch code
                ie.printStackTrace();
            }
        }
    }  
}
class xiancheng1 extends Thread
{
    public xiancheng mt;//这句话是什么意思???? 求大神解释
    public void run()
    {
        for (int i=0;i<20;i++) {
            System.out.print("●");
            try {
                thread.sleep(1000);
            } catch (Exception e) {
                e.printStackTrace();
            }
            if(i==10)//当i等于10时,停止线程2的运行,执行线程1和线程3,在线程1和线程3运行完后再运行线程2直到结束
            {
                try {
                    mt.join();
                } catch (InterruptedException ie) {
                    
                    ie.printStackTrace();
                }
            }