Why the following code is not printing "after wait".
My understanding is that call to wait() will move
the
thread to the pool of waiting threads. Since
there are no threads waiting, this thread should
get access to the CPU again to complete its work.
But this is not happening.
I am sure I am missing some big concept on wait and
notify. Please clear my doubt.
Regards
Sanjay
class thread extends Thread
{
public void run()
{
System.out.println("before wait");
synchronized(this)
{
try
{
wait();
notify();
}
catch(InterruptedException ioe){}
}
System.out.println("after wait");
}
public static void main(
String argv[])
{
Thread t= new thread();
t.start();
}
}