I have heard it said that one should never use an if condition in a synchronized block (and should replace it with a while) because if a
thread slices out in the middle of executing the if condition then the condition that it was attempting to evaluate before being sliced out could be different when that thread slices back in because another thread could have changed it and this a problem because an if (unlike a while) continues execution from where it left off.
I have done this with my code and have found that it produces peculiar looking code. For example:
In this code will there be an endless stream of exceptions thrown? Are there cases when we can't just simply change 'if' to 'while'?
Cheers