Originally posted by robert stannard:
Hi Taariq,
Thank you thats excellent. I tried both your solutions and they both worked perfectly.
Whats a confusing for me is that your solutions can only work by adding in the "Thread.sleep(1000);" line. I guess this is to ensure that that the notifyAll() doesnt run before the wait() has had a chance to secure a lock on that object?
Regards
Robert.
You're welcome, and 100% right. If you remove the sleep the output is...
Trying to Notify
Waiting
It takes a few milliseconds longer to get the thread going and by that time restart method has been called already.
I tested it with Thread.sleep(1); and it worked, but I ran it on Windows which isn't accurate down to the millisecond, so 1 millisecond is about 10 milliseconds. Anyhat, seems to need just that breather to get going.