I have two streams. In one thread that started immediately there is such a code.
public void run(){ MONITOR.wait(); ...} In the second thread, which starts 10 seconds after the first, such code:
public void run(){ MONITOR.notify(); MONITOR.wait();...} Can it happen that both threads will be in wait ? Such a question I was asked at the interview, I said that I could not, I was told you were mistaken, think. Who was right? Java dock on my side, but still wanted to clarify. Can you give an example of a situation where both threads will be in a wait at the same time, due to some reasons? The first thing that comes to mind on the second question is to change the wait and notify in the second thread in some places.