Thiyagarajan Kamala wrote:
I did a small change to wait to synchronize on class level but the notification is not happening.Kind of confused ...asusual on this things......
if you will put some output in the block where you notifying, you will see that this block realy runs before the waiting block runs. So you first notify on object and then lock and wait on it. You put 1st
thread to sleep 1000ms, then 2nd thread runs a bit and goes sleep 1000ms, whilst 1st wakes first and does it's notify evil thing. After that 2nd thread wakes and procedes to its wait, but in vain, no notifies left there for him.