we could also say that it waits quietly for the JVM to tell it that the lock is available. It's similar to wait/notify,
Alain Dickson wrote:well, can we say for sure that the Thread which is blocked, waits until the lock becomes available
And that:
1. It does not wake up in-between to check if the lock is available
Alain wrote:2. When the lock becomes available, Which notification JVM uses notify() OR notifyAll()
"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5
Alain Dickson wrote:Thanks Mike,
Though from the discussion it makes sense both sychronized method calls and wait/notify are similar systems in terms of blocking thread and make it wait, but I would like to explicitly ask that: I have a situation where the design suggests to use wait/notify but I am thinking of redesigning it into synchronized method calls where (behaviour of wait/notify) is done by JVM not by program calling wait and notify explicity, which is prone to errors as compared to calls to synchronized methods. If the design allows, will synchronized methods give similar performance as wiat/notify where I know no thread will wake up until I call notify/notifyAll?
Thanks,
Alain
Steve