本帖最后由 henha2jiang 于 2012-08-11 12:42:52 编辑

解决方案 »

  1.   


    public class Test1
    {
        public static void main(String args[])
        {
        MyThead mt = new MyThead();
        mt.start();
        for(int i = 0;i<10;i++)
        {
        try
        {
        Thread.sleep(1000);
        }
        catch(InterruptedException e)
        {
        e.printStackTrace();
        }
        System.out.println(i+"ThreadDemo");
        }
        }
    }class MyThead extends Thread
    {
        public void run()                                 //重写run方法
        {
         for(int i=0;i<10;i++)
         {
         try
    {
    Thread.sleep(1000);                   //使用sleep方法让当前线程休眠1000毫秒
    } catch (InterruptedException e)
    {
    e.printStackTrace();                  
    }
         System.out.println(i+"MyThread");
         }
        }
    }
      

  2.   

    这就类似于函数参数,是别人实例化好了才传递给你的。public void fun(InterruptedException e) {
      e.printStackTrace();
    }
    你可以理解为Thread.sleep()这个函数,内部有这么一句话:
      throw new InterruptedException();
      
      

  3.   

    InterruptedException e语句里面前面是Exception 类型,后面是随便安的名字,用类名调用Thread的...方法,是异常里面的方法哈,查API看就知道了,不是很明了吗。
      

  4.   

    说错了,是异常抛出的对象,不是Thread。