Originally posted by Sharda:
If a call to wait/notify must be within synchronized code, then why does it not complain at compile time. Is it not syntactically incorrect?
I think it compiles because it is possible that any other
thread (not mentioned in current compilation
unit) via a synchronized method could be calling this method. To demonstrate that I have just added one more layer of call in your code, and it compiles and runs fine...