线程-run和start

import java.lang.Thread;
class Machine extends Thread{
    public void run()
    {
        int a ;
        for( a = 0 ; a < 50 ; a ++ )
        {
            System.out.println(currentThread().getName()+":"+a);
            try{
                sleep(100);
            }catch(InterruptedException e){
                throw new RuntimeException(e);
            }
        }
    }
}
public class Static {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Machine machine1 = new Machine();
        Machine machine2 = new Machine();
        machine1.start();
        machine2.start();
        machine1.run();
    }
}

 

posted @ 2016-07-28 11:13  指间ゝ繁华初逝的格调  阅读(104)  评论(0编辑  收藏  举报