Can anyone explain about wait() and notify() method giving some example.
Thanks in advance.
Joined: Feb 28, 2007
See the code below:
Try to run this, with Line1 and Line 2 and without Line 1 and Line 2. Without Line 1 - Line 2, the output is indeterministic but with wait(), the output is surely "sum = 55". with wait, main waits for thread ww to notify it before it could print the result.