title: Why thread not going into waiting status for infinite time?
body: <p>Below is the code piece which successfully finishes the execution when I run it in my local machine. </p>
  
  <p>I cannot understand why this thread is not going into infinite wait status ? </p>
  
  <pre><code>public class Job extends Thread {
  
      private int counter;
  
      @Override
      public void run() {
          synchronized (this) {
              for (int i = 0; i &lt; 100000; i++) {
                  counter++;
              }
  
              this.notifyAll();
          }
      }
  
      public static void main(String[] args) throws InterruptedException {
          Job job = new Job();
          job.start();
          synchronized (job) {
              job.wait();
          }
  
          System.out.println(job.counter);
      }
  }
  </code></pre>
  
  <p>Is there any gurantee that above code will always finish execution in every condition ? Can anybody clarify ?</p>