title: Why does notifyAll() raise IllegalMonitorStateException when synchronized on Integer?
body: <p>Why does this test program result in a <code>java.lang.IllegalMonitorStateException</code>?</p>
  
  <pre><code>public class test {
      static Integer foo = new Integer(1);
      public static void main(String[] args) {
          synchronized(foo) {
              foo++;
              foo.notifyAll();
          }
          System.err.println("Success");
      }
  }
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalMonitorStateException
          at java.lang.Object.notifyAll(Native Method)
          at test.main(test.java:6)
  </code></pre>