ashwin bhawsar wrote:I have a Counter Class with two methods : increaseCount() and decreaseCount().
I also have two threads. Thread_1's run calls the increaseCount() and Thread_2's run calls the decreaseCount().
Both threads share a common instance of Counter class.
Now, what i want is Thread_2 to execute decreaseCount() only after Thread_1 has finished executing the increaseCount().
( i know this can be done with join() method, but want to achieve the same thing using wait() and notify() )
I have made the Thread_2 to wait till the Thread_1 completes its execution. After Thread_1 finishes its execution it call the notify() on the shared object.
But the problem is that Thread_2 keeps on waiting even after Thread_1 notifies it. Why ? am i missing something ?