Consider the following execution statements:
(1) Thread A: Checks for a specific lock state and fails (2) Thread A: Hence tries to go to wait state (3) Thread B : Done with a specific task and modified the lock state desired by Thread A (4) Thread B : Signals notifyAll()
Consider if Java's VM reorders the code to execute in the following order (1),(3),(4),(2). I believe such a condition is possible and in such a case, there might be an issue, because the Thread A goes to wait state forever as there is no other thread to notify!
EDIT 1: I am not using Synchronized block for the purpose of locking. Rather I am using AtomicInteger to gain a lock on a piece of code. Consider a RWLock Class and it has an atomic variable N. With the number of Readers and Writers coming in the lock state is incremented or decremented. The question is applicable to such a condition and not synchronized blocks/ methods.