In Java concurrency, one rule pops up repeatedly:
Always wrap wait() in a while loop, not an if statement.
But why? What’s wrong with using if? After all, if the condition isn’t met, we wait — and if we’re notified, we proceed. Sounds simple, right...