I am new to multithreading with Java. I\'ve done some research, read tutorials, and done tests, but I\'m stuck with this problem. Basically, I\'m setting up the skeleton of
The MainLoopThread
instance waits on this
(an instance of MainLoopThread
), and the GFXUnpack
instance notifies on this
(an instance of GFXUnpack
). So the notifier doesn't notify the waiting thread.
The two objects must use the same object instance to wait and notify. And even better, you should use higher-level abstractions from the java.util.concurrent
package, like Semaphores, CountDownLatches, etc., rather than these hard to use low-level methods.
Moreover, wait()
should always be called in a loop that checks if the condition necessary to wake up is realized and starts waiting again if it's not, due to spurious wakeups.