adithya narayan wrote:
1)Can anyone explain what went wrong?
2)The program didn't terminate. How do i terminate it?
The notify() method doesn't trigger the wakeup, context switch, etc.... all it does is send the notification to a waiting thread.
Your waitandnotifytest thread just sends the notification, and does so blindly in a loop (no flag to confirm receipt, or that a thread is waiting)... see point one and two. This causes a bunch of missed notifications.
Steve
adithya narayan wrote:
I am still unable to get to the output which i had desired i.e. The notifying thread should increment the value of the counter only after the waiting thread finishes its previous execution based on the notification sent by the notifying thread ! Also,the notifying thread shouldn't notify for the same event again. Can anyone suggest something ?
Steve
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|