PS:Class exposes synchronization and semaphores in its public interface 
This class uses synchronization along with wait(), notify() or notifyAll() on itself (the this reference). Client classes that use this class, may, in addition, use an instance of this class as a synchronizing object. Because two classes are using the same object for synchronization, Multithread correctness is suspect. You should not synchronize nor call semaphore methods on a public reference. Consider using a internal private member variable to control synchronization. 
 public synchronized void addMsg(MuxRollCastParaMsg _msg)
 {
       priorityList.add(_msg);
       this.notifyAll();
 }

解决方案 »

  1.   

    这是FindBugs给你的提示?
      

  2.   

    是的啊,是不是这样改?
     public  void addMsg(MuxRollCastParaMsg _msg)
     53:     {
     54:         synchronized(priorityList)
     55:         {
     56:             priorityList.add(_msg);
     57:             this.notifyAll();
     58:         }
     59:     }
      

  3.   

    这是一个关于线程同步的问题嘛。
    方法像你这样声明:
    public synchronized void addMsg(MuxRollCastParaMsg _msg) 表示对于这个对象同步。
    public synchronized void addMsg(MuxRollCastParaMsg _msg) //这个方法在本对象(this)同步

          priorityList.add(_msg); 
          this.notifyAll(); //唤醒对于this同步的线程
    } 那段英文你自己看吧,我就不详细的写解释了。大概意思就是说,你的同步方法(同步在本对象上)是public,那么
    有其他的类的对象用这个类,把这个类的实例作为同步对象,
    这样,就相当于两个类对同一个同步对象了。
    它建议你用一个私有成员变量来控制同步。
      

  4.   


    你这么修改确实是用 私有成员变量 来控制同步了。但你不应该用this.notifyAll(); 
    而应该用 priorityList.notifyAll(); 
    因为你的意思是,方法在priorityList上同步。如果this.notifyAll(); 会抛异常,因为调用 .notifyAll(); 方法必须持有该对象的锁。
    这里说的该对象就是 调用.notifyAll(); 的this,你并没有对 this同步,也就没有持有这个锁。