title: IllegalMonitorStateException with ArrayList NotifyAll() Wait()
body: <p>I know there are many answers on this topic and I think I have read them all.
  Most of the answers do not include the namespace they use, and compiling the code they suggest is virtually impossible.</p>
  
  <p>I am using VS 2015 Comunity with Xamarin and this is an Android project.</p>
  
  <p>My namespaces:</p>
  
  <pre><code>using Android.Graphics;
  using Android.Util;
  using Java.Lang;
  using Java.Util;
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>public static int updateWait()    // Called by a thread.
  {
      int value = 0;
  
       try
      {
          while (msgList.IsEmpty)
          {
              msgList.Wait();
          }
          value = (int)msgList.Get(0);
          msgList.Remove(0) ;
      }
      catch (Exception e)
      {
          Log.Debug("", "" + e);
      }
      return value;
  }
  
  public static void updateNotify()   // called by a service
  {
      if (msgList.IsEmpty)
      {
          msgList.Add(1000);
      }
      try
      {
              msgList.NotifyAll();
      }
      catch ( Exception e)
      {
          Log.Debug("", "" + e);
      }
  }
  </code></pre>
  
  <p>The above code works <strong>correctly</strong>, since the thread from an activity seems to be blocked until the service calls <code>updateNotify()</code>. The problem is <code>IllegalMonitorStateException</code> are generated for every call to <code>msgList.NotifyAll()</code>, which I am ignoring.<br>
  Since only one thread notifies, and only one waits, there are no synchronization issues - but the exceptions are worrying.</p>