Regarding wait and notify
<p>I was developing the simple code related to wait &amp; notify I have created two seprate classes , below are the classes </p>

<pre><code>    class ThreadA {
 public static void main(String [] args) {
 Thread b = new Thread();
 b.start();

 synchronized(b) {
 try {
 System.out.println("Waiting for b to complete...");
 b.wait();
} catch (InterruptedException e) {}
 //System.out.println("Total is: " + b.totals);
 }
}
}

and the other one is ...





class ThreadB extends Thread {
public  int totals;

 public void run() {
     synchronized(this) {
     for(int i=0;i&lt;100;i++) {
      totals += i;
      }
      notify();
      }
      }
     }
</code></pre>

<p>but inside class ThreadA, I am getting the complie time error when I am accessing the totals from b thread object that is ..</p>

<pre><code>System.out.println("Total is: " + b.totals);
</code></pre>

<p>Please advise me how to correct it so that I can execute my code..!! thanks in advance ..!1</p>
