title: Kind of a Rendez-Vous in Java which does not work
body: <p>I have some troubles using <code>wait()</code> and <code>notify()</code>. I need to have a kind of <em>rendez-vous</em>.</p>
  
  <p>Here is the thing, in a small piece of code:</p>
  
  <pre><code>class A {
      private Rdv r;
  
      public A(Rdv r) {
          this.r = r;
      }
  
      public void someMethod() {
          synchronized(r) {
              r.wait();
          }
  
          // ***** some stuff never reached*****
      }
  }
  
  class Rdv { 
      private int added;
      private int limit;
  
      public Rdv(int limit) {
          this.added = 0;
          this.limit = limit;
      }
  
      public void add() {
          this.added++;
  
          if(this.added == this.limit) {
              synchronized(this) {
                  this.notifyAll();
              }
          }
      }
  }
  
  class Main {
      public static void main(String[] args) {
          Rdv rdv = new Rdv(4);
  
          new Runnable() {
              public void run() {
                  A a = new A(rdv);
                  a.someMethod();
              }
          }.run();
  
          rdv.add();
          rdv.add();
          rdv.add();
          rdv.add();
      }
  }
  </code></pre>
  
  <p>The idea is to wait until 4 threads tell "hey, i'm done" before to run the end of <code>someMethod()</code>.
  But the <code>wait()</code> lasts forever, despite of the <code>notifyAll()</code>.</p>
  
  <p>I don't get how </p>