if i am not wrong ,if many threads act on an object ,using "notify()" will affect only one of them,where as "notifyAll()" will notify all of the threads that are waiting on a particular object.
Consider the below example
when i use notifyAll i get the following output:
D:\scjp>javac Reader.java
D:\scjp>
java Reader
A waiting for calculation....
B waiting for calculation....
C waiting for calculation....
going inside Calculators syn block
inside Sync block
Total of
Thread Cis4950
Total of Thread Bis4950
Total of Thread Ais4950
when i use notify i get the following output:
D:\scjp>javac Reader.java
D:\scjp>java Reader
A waiting for calculation....
C waiting for calculation....
B waiting for calculation....
going inside Calculators syn block
inside Sync block
Total of Thread Ais4950
Total of Thread Bis4950
Total of Thread Cis4950
Now my question is:"notify()" should notify only one of the thread how is that all the threads is getting notified?