java,定义一个Thread类的继承类,并覆盖run方法,在run方法中每隔100毫秒打出一句话

package wanzai;

public class Test1 {

    public static void main(String[] args) {
        
        TestThread tt=new TestThread();
        tt.start();
        Thread tt1=new Thread(new TestThread1());
        tt1.start();
        

    }

}
package wanzai;

public class TestThread extends Thread {
    public void run()
    {
        for(;;)
        {
            System.out.println("0000000");
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                
                e.printStackTrace();
            }
        }
    }

}
package wanzai;

public class TestThread1 implements Runnable {

    @Override
    public void run() {
        
            for(;;)
            {
                System.out.println("0000000");
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    
                    e.printStackTrace();
                }
            }
        }
        
    }
    

posted @ 2016-03-15 16:22  什么玩楞啊,我叫旺仔  阅读(1091)  评论(0编辑  收藏  举报