what will happen if i call wait method on object outside of synchronisation block? [duplicate]
Possible Duplicate:
Why wait should always be in synchronized block
What will happen if I call wait() and notify(), notifyAll() method outside of synchronization ? Does it has any effect ?
example
Class Test(){
Test(){
I know I am writing empty try catch
try{
wait();
notify();
notifyAll();
}catch (Exception ex)
}
}
You get an IllegalMonitorStateException,
IllegalMonitorStateException - if the current thread is not the owner of the object's monitor.
精彩评论