title: How to wake up threads of different instances?
body: <p>I have many instances of the same object, and i would like to start a thread for each instance.
  My threads should be synchronized, so each thread share a common object that I lock every time, as you can see in my code:</p>
  
  <pre><code>public Person(String name, Object1 o){
      this.name = name;
      this.obj1 = o;
  }
  
  public boolean addToList(){
      boolean locked;
      locked = obj1.getLock().tryLock();
      System.out.println(this.name+" try to lock");
      while (!locked){
          try{
              obj1.wait();
          }catch (InterruptedException e){
              System.out.println("Error!");
          }
          locked = obj1.getLock().tryLock();
      }
  
      System.out.println(this.name+" lock ok");
      if(obj1.getPerson().size()&lt;obj1.getNum()){
          System.out.println("0 "+name+" list size: "+obj1.getPerson().size());
          obj1.getPerson().add(this);
          System.out.println("1 "+name+" list size: "+obj1.getPerson().size());
          obj1.getLock().unlock();
          System.out.println("Unlock ok");
          obj1.notifyAll();
          System.out.println("Notifyall ok");
          return true;
      }
      return false;
  }
  </code></pre>
  
  <p>I don't understand why, after the first addToList(), the other threand won't wake up!</p>