Call wait() from a Class on other Thread
<p>I want to call <code>wait()</code> on other Thread becoz if my current class some part of code is executing don't want to interrupt by other thread..
for this i m doing like this</p>

<p>main.class</p>

<pre><code>testThread as=new testThread();
try{
    synchronized(as) {
        wait();
    }
} catch (Exception e) {
    Log.d(tag, "In ==Scheduler== error"+e.toString());
}
</code></pre>

<p>testThread.class</p>

<pre><code>public void run() {
    while(true) {
        System.out.println("Thread"); 
        try {
            Thread.sleep(6000);
        } catch(Exception r) {

        }
    }
}
</code></pre>

<p>And getting the following error</p>

<blockquote>
  <p>error java.lang.IllegalMonitorStateException: object not locked by thread before wait()</p>
</blockquote>

<p>Why am I getting this error, and how can I fix it?</p>
