M
Madhur Ahuja
Hello
I am making a simple multithreaded sorting program.
The main program instantiates a new thread which carries out sorting and
prints out the result. This requires the use of wait function as shown
below.
However the IllegalMonitorStateException occurs stating that current thread
is not
the owner of the object. I have tried all methods specified in the
documentation of
the *notify* function, but no avail.
What change should I make below in order to correct the error.
class qapp
{
public static void main(String args[]) throws InterruptedException
{
Thread t=Thread.currentThread();
qsort qr=new qsort(t);
System.out.println(t.toString());
qr.input();
qr.start();
t.wait(); // <-------------Exeception Line
System.out.println("\nThe sorted numbers are:");
qr.display();
}
}
Exception in thread "main" java.lang.IllegalMonitorStateException: current
threa
d not owner
--
Winners dont do different things, they do things differently.
Madhur Ahuja
India
Homepage : http://madhur.netfirms.com
Email : madhur<underscore>ahuja<at>yahoo<dot>com
I am making a simple multithreaded sorting program.
The main program instantiates a new thread which carries out sorting and
prints out the result. This requires the use of wait function as shown
below.
However the IllegalMonitorStateException occurs stating that current thread
is not
the owner of the object. I have tried all methods specified in the
documentation of
the *notify* function, but no avail.
What change should I make below in order to correct the error.
class qapp
{
public static void main(String args[]) throws InterruptedException
{
Thread t=Thread.currentThread();
qsort qr=new qsort(t);
System.out.println(t.toString());
qr.input();
qr.start();
t.wait(); // <-------------Exeception Line
System.out.println("\nThe sorted numbers are:");
qr.display();
}
}
Exception in thread "main" java.lang.IllegalMonitorStateException: current
threa
d not owner
--
Winners dont do different things, they do things differently.
Madhur Ahuja
India
Homepage : http://madhur.netfirms.com
Email : madhur<underscore>ahuja<at>yahoo<dot>com