要实现你所描述的功能,只要一个计数器,不用线程就可以实现了。
计数器i,用timer类,每隔1秒输出i和100-i。

解决方案 »

  1.   

    to hyhong_h(黄黄) 
    我只是想看看大家线程是如何实现的,书上的程序让我摸不着头脑,所以请写一个实现上述功能的能体现线程基本用法的最简单的程序。
    第一个给出的得全分。
      

  2.   

    //TestThread.java
    import java.lang.*;
    Thread1 extends Thread{
       int count1=0 ;
       //初始化类Thread1
       public Thread1(){     
       }
       void add(){
         count1 = count1 +1 ;     
       }
       //start
       void run(){
        for (int i=0;i<100;i++){
         add();
        }
       }
    }public class TestThread1 {
       public static void main(String[] args){
         for (int i=0;i<100;i++){
             test = new Thread1();  //这些事例同时执行
             test.run();                        
         }
       }
    }
      

  3.   

    to Whyin(孤刀浪子) 好象不合要求吧?我要的是两个线程啊!其实我是想看一下线程程序的大体结构是怎么样的?如果能给我说一下什么地方应该写什么就更好了,不一定非要写详细的代码。
      

  4.   

    TO:hyhong_h(黄黄),实际上java timer也用了线程的概念实现的,不信的话,你可以看看java API就明白了。