I'm having a problem with my wait / notify code. I understand pretty much how it all works, but the problem is that notify() is being called before wait() and I'm not sure the best way to fix it.
Rather, than post my entire code, I've created this little application which demonstrates the problem.
The associated output is:
running...
wait...
Do something...
doing it...
...done it
notify...
Do something again...
doing it...
...done it
notify...
wait...
I can see why the problem happens, but is there an elegant way to solve it?
Cheers,
James
PS - Why I'm here, can anyone suggest a more elegant solution than "Thread.sleep(1000);" ?