
public class P3 extends Thread{
void waitForSignal() throws InterruptedException {
Object obj = new Object();
synchronized (Thread.currentThread()) {
obj.wait();
obj.notify();
}
}
public static void main(String[] args) throws InterruptedException {
P3 t=new P3();
t.waitForSignal();
}
}
Explain the flow of output..
output:
Exception in thread "main" java.lang.IllegalMonitorStateException at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:485) at P3.waitForSignal(P3.java:7) at P3.main(P3.java:13)