Hi, I tried an example for wait() after reading a tutorial.
The Example is as below:
On executing theabove I get the below error.
Exception in thread "main" java.lang.IllegalMonitorStateException: current thread not owner at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:474) at com.aciworldwide.application.TestApp.main(TestApp.java:19)
Where am I doing wrong.What does the error mean how can I correct it?
* Thread should obtain the object's monitor before invoking wait() or notify() on it. * Locks,synchronized blocks/methods are the techniques to acquire object monitor. Depending on application requirement,suitable technique should be adopted. * wait() should always be matched with a notify(). If you get rid of java.lang.IllegalMonitorStateException in the above example by aquiring the object's(one) monitor,main-thread will wait for-ever. * You may find this discussion helpful. [ June 05, 2008: Message edited by: sarvesh meens ]