title: Concept behind putting wait(),notify() methods in Object class
body: <p>I am just having hard time to understand concept behind putting <code>wait()</code> in <code>Object</code> class.  For this questions sake consider if <code>wait()</code> and <code>notifyAll()</code> are in <code>Thread</code> class.</p>
  
  <pre><code>class Reader extends Thread {
      Calculator c;
      public Reader(Calculator calc) {
          c = calc;
      }
  
      public void run() {
          synchronized(c) {                              //line 9
          try {
              System.out.println("Waiting for calculation...");
              c.wait();
          } catch (InterruptedException e) {}
              System.out.println("Total is: " + c.total);
          }
      }
  
      public static void main(String [] args) {
          Calculator calculator = new Calculator();
          new Reader(calculator).start();
          new Reader(calculator).start();
          new Reader(calculator).start();
          calculator.start();
      }
  }
  
  class Calculator extends Thread {
      int total;
      public void run() {
          synchronized(this) {                     //Line 31
              for(int i=0;i&lt;100;i++) {
                  total += i;
              }
               notifyAll();
          }
      } 
  }
  </code></pre>
  
  <p>My Question is that what difference it could have made? In line 9 we are acquiring lock on object c and then performing wait which satisfy the condition for wait that we need to acquire lock on the object before we use wait and so is case for notifyAll we have acquired lock on object of Calculator at line 31.</p>