第一个:
int n = 300;
public void run(){
 while(n > 0){
  System.out.print(n-- + "  ");
  try{
   Thread.sleep(1000);
  }
  catch(InterruptedException e){}
}
System.out.print(300);
}
第二个问题不太明白楼主什么意思

解决方案 »

  1.   

    public class TestThreadExample1 implements Runnable
    {
        private int start=300;
        public void run()
        {
            for(int i=start;i>=0;i--)
                System.out.println(i);
            System.out.println(start);
        }
        public static void main(String[] args)
        {
            new Thread(new TestThreadExample1()).start();
        }
    }
      

  2.   


    public class TestThreadExample2 implements Runnable
    {
        int start=300;
        public void printByeInfo(String info)
        {
            System.out.println("I am going to stop running at once!,I am "+info);
        }
        class ChildThread implements Runnable
        {
            String name;
            public ChildThread(String name)
            {
                this.name = name;
            }
            public void run()
            {
                for(int i=0;i<start;i++)
                {
                    try
                    {
                        Thread.sleep(10);
                    }catch(Exception ex)
                    {
                        ex.printStackTrace();
                    }
                };
                printByeInfo(""+name+" 号子线程");
            }
        }
        public void run()
        {
            new Thread(new ChildThread(" 1 ")).start();
            new Thread(new ChildThread(" 2 ")).start();
            new Thread(new ChildThread(" 3 ")).start();
            printByeInfo("主线程");
        }
        public static void main(String[] args)
        {
            new Thread(new TestThreadExample2()).start();
        }
    }
      

  3.   

    我觉得第一个有点问题,按照feiyuegaoshan(飞跃) 大哥和我第一个程序的输出应该是:
    300
    299
    而题的意思是倒计时那样,300过后消失再显示299