Hello Manju,
Please go through
this discussion first, will give some ideas.
Two thumb rules here Manju.
1. What happens when a thread does not call notify()?
You call it Spurious wakeup. That's a thread can wakeup itself in such a condition. Thats's why you got this output. Again, this behavior is not guranteed.So, dont rely on it.
2. What happens when a thread calls notify() and notifyAll(), but there are no threads to be notified?
You loose nothing; the notify() simply returns without doing anything great.
Hope, it helps.