Posted By:
Amit_Saxena
Posted On:
Monday, December 8, 2003 11:23 PM
I made two threads both doing their task respectivelly. I want when the first thread starts then at the same time the other thread should also start.For this I invoked the wait method on the first thread & invoked notifyAll() on the other thread but this leads to this exception on the first thread:- java.lang.IllegalMonitorStateException: current thread not owner So how should I rectify this error & why this error had occured ?? The Code is :- Thread_one iothread_one = new Thread_one(); iothread_one.start(); try { /*Here at this below line this IllegalMonitorStateException occurs. */ iothread_one.wait(); } catch(InterruptedException
More>>
I made two threads both doing their task respectivelly. I want when the first thread starts then at the same time the other thread should also start.For this I invoked the wait method on the first thread & invoked notifyAll() on the other thread but this leads to this exception on the first thread:-
java.lang.IllegalMonitorStateException: current thread not owner
So how should I rectify this error & why this error had occured ??
The Code is :-
Thread_one iothread_one = new Thread_one();
iothread_one.start();
try
{
/*Here at this below line this IllegalMonitorStateException occurs. */
iothread_one.wait();
}
catch(InterruptedException e)
{
System.out.println("Exception caught ====>>>" + e);
}
Thread_second iothread_second = new Thread_second();
iothread_second.start();
iothread_second.notify();
<<Less