I have a little problem here. Supposed there are 2 threads. The first thread has a call to wait(), and the second thread has a call to notify(). Now, assume that both calls are synchronized on the same object. If the first thread calls wait(), the second thread will "wake up" the thread with the notify() method. However, since we can't know for sure which thread runs first (it's all up to the thread scheduler), what if the second thread runs first? Doesn't it mean that the notify() method is called before the wait() method? What will happen in this scenario, and any way to prevent this?
Current Status:<br /> <br />SCJP 1.4<br />SCJD (in progress)