Regarding notifying a particular thread deleibrately
<p>I have developed the below java code ..</p>

<pre><code>   class ThreadB extends Thread {
public  int totals;

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

<p>and the other class is...</p>

<pre><code>        class ThreadA {
     public static void main(String [] args) {
     ThreadB b1 = new ThreadB();
     b.start();
ThreadB b2 = new ThreadB();
b2.start();
ThreadB b3 = new ThreadB();
b3.start();
ThreadB b4 = new ThreadB();
b4.start();

     synchronized(b) {
     try {
     System.out.println("Waiting for b to complete...");
     b1.wait();
b2.wait(); //only b2 to be notified
b3.wait();
b4.wait();
    } catch (InterruptedException e) {}
    System.out.println("Total is: " + b.totals);
     }
    }
    }
</code></pre>

<p>No please advise me that I want to notify only thread b2 and b2 only , how I would achieve this , since notify thread can pick up any one thread , but I want only b2, please advise. </p>
