title: scjp: threads related issue
body: <p>below is the question...</p>
  
  <pre><code>void waitForSignal() {
       Object obj = new Object();
       synchronized (Thread.currentThread()) {
           obj.wait();
           obj.notify();
       }
   }
  </code></pre>
  
  <p>Which statement is true?</p>
  
  <p>A. This code can throw an <code>InterruptedException</code>.</p>
  
  <p>B. This code can throw an <code>IllegalMonitorStateException</code>.</p>
  
  <p>C. This code can throw a <code>TimeoutException</code> after ten minutes.</p>
  
  <p>D. Reversing the order of <code>obj.wait()</code> and <code>obj.notify()</code> might cause this method to complete normally.</p>
  
  <p>E. A call to <code>notify()</code> or <code>notifyAll()</code> from another thread might cause this method to complete normally.</p>
  
  <p>F. This code does NOT compile unless <code>obj.wait()</code> is replaced with <code>((Thread) obj).wait()</code>.</p>
  
  <p>Answer is B . But when i have executed in below manner getting A. Please help.</p>
  
  <pre><code>public class ThreadStateProblem extends Thread {  
      public void run() {  
  
      }  
  
      void waitForSignal() {
          Object obj = new Object();
          synchronized (Thread.currentThread()) {
              obj.wait();
              obj.notify();
          }
      }
  
      public static void main(String []s) {  
          new ThreadStateProblem().start();  
          new ThreadStateProblem().waitForSignal();
      }    
  }   
  </code></pre>
  
  <p>And also tried below : </p>
  
  <pre><code>public class ThreadStateProblem extends Thread {  
      public void run() {  
  
      }  
  
      void waitForSignal() {
          Object obj = new Object();
          synchronized (Thread.currentThread()) {
              obj.wait();
              obj.notify();
          }
      }
  
      public static void main(String []s) {  
          ThreadStateProblem sd =new ThreadStateProblem();
          sd.start();
          sd.waitForSignal();
      }    
  }  
  </code></pre>