I have developed the below java code
<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();
        }
    }
}
</code></pre>

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

<pre><code>class ThreadA {
    public static void main(String[] args) {
        ThreadB b = new ThreadB();
        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);
        }
    }
}
</code></pre>

<p>No please advise me how to create a scenario where multiple threads is waiting for it, rite now only one thread is waiting, I want to create where multiple threads lets say 4 threads are waiting for Thread B to complete it's task first..!!please advise, thanks..!!</p>
