Runtime.exec throws IllegalMonitorStateException sometimes
<p>We have following code which sometimes throws java.lang.IllegalMonitorStateException: unlock of unowned monitor</p>

<pre><code>Runtime run = Runtime.getRuntime();
Process p = run.exec(SOME_COMMAND);
</code></pre>

<p>This code is executed quite early while the application start.</p>

<p>It works fine if I start the application manually. I have never seen any problems with it (for hunders of launches).</p>

<p>However, when it's started as part of testing automation sometimes this code fails with that exception.
Our testing automation does following:</p>

<ul>
<li>install our app</li>
<li>launch it immediately</li>
<li>execute some tests</li>
<li>uninstall app</li>
<li>install app again</li>
<li>launch it again</li>
</ul>

<p>Here is the stack track of the crash.</p>

<pre><code>  11-14 14:59:26.675: W/dalvikvm(3788): threadid=12: thread exiting with uncaught exception (group=0xb4120180)
    11-14 14:59:26.675: E/AndroidRuntime(3788): FATAL EXCEPTION: SomeThread
    11-14 14:59:26.675: E/AndroidRuntime(3788): java.lang.IllegalMonitorStateException: unlock of unowned monitor
    11-14 14:59:26.675: E/AndroidRuntime(3788):     at java.lang.ProcessManager.exec(ProcessManager.java:229)
    11-14 14:59:26.675: E/AndroidRuntime(3788):     at java.lang.Runtime.exec(Runtime.java:168)
    11-14 14:59:26.675: E/AndroidRuntime(3788):     at java.lang.Runtime.exec(Runtime.java:241)
    11-14 14:59:26.675: E/AndroidRuntime(3788):     at java.lang.Runtime.exec(Runtime.java:184)
    11-14 14:59:26.675: E/AndroidRuntime(3788):     at aaa.SomeThread.run(SomeThread.java:41)
</code></pre>

<p>I appreciate any ideas or information.</p>
