1

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)
  }
}
Community
  • 1
  • 1
Neel Salpe
  • 1,287
  • 3
  • 15
  • 26

1 Answers1

3

You get an IllegalMonitorStateException,

IllegalMonitorStateException - if the current thread is not the owner of the object's monitor.

nos
  • 223,662
  • 58
  • 417
  • 506