It's not totally clear what behaviour you are attempting to implement. Can you explain?
I can see that the program may well hang. Although you have two notify() and two wait() calls, you have not guaranteed that anyone is waiting when you do your notifications. Therefore, one or both notify() calls may happen when there is no wait() in progress. Then, one or more of the wait() calls will wait forever in vain.
A final point. This situation is not "deadlock". Deadlock is where two threads are trying to acquire one of two resources, where one thread already holds one of the resources and the other thread holds the other resource. In this situation, the threads will be stuck forever trying to enter the synchronized block.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Joined: Jul 19, 2004
Yeah u right Even i dont know what i am trying to implement, i just thought of writing some piece of code using Wait and Notify, got this problem during running, well, i think now i have got to know what the problem is