what will be the disadvantage if we will use notify immediately before wait
问题 I was reading this Java: notify() vs. notifyAll() all over again. xagyg has given a good example there. I just want to know if I put notify immediately before the wait like below, will it solve the problem of deadlock? Please explain. while (buf.size()==MAX_SIZE) { notify(); wait(); // called if the buffer is full (try/catch removed for brevity) } and while (buf.size()==0) { notify(); wait(); // called if the buffer is empty (try/catch removed for brevity) // X: this is where C1 tries to re