你这里的load.change(count);的这个load没有实例话,是个空对象阿。他不是着不到count而是找不到load。你可以这样改的
class Counter extends Thread{
   CounReload load=new CounReload();
   String name;
public static int count=0;
......

解决方案 »

  1.   

    import java.io.*;
    public class bean5 {
    public static void main(String args[]){
        new Counter("A");
        new Counter("B");
        new Counter("C");
        new Counter("D");
        try{Thread.sleep(10000);}
         catch(InterruptedException e){}
      }
    }
    class Counter extends Thread{
       CounReload load;
       String name;
       int count=0;
       Counter(String name){
         this.name=name;
         new Thread(this,"dfds").start();
       }
       public void run(){
         while(true){
         System.out.print(name+" ");
         new CounReload().change(count++);     try{Thread.sleep(100);}
         catch(InterruptedException e){}
         }
       }
    }
    class CounReload{
       synchronized void change(int c){
         System.out.println("count:    "+c);
        }
    }