title: Android: java.lang.IllegalMonitorStateException: object not locked by thread before wait()
body: <p>I have this this code for Android which is stuck at the synchronized statement. Even if i remove the process1.wait() i catch the exception.any help is appreciated?</p>
  
  <pre><code> private class LongOperation extends AsyncTask&lt;String, Void, String&gt;
     {
  
        @Override
        protected String doInBackground(String... params)
        {
           try
           {
       Process process1 = new ProcessBuilder("sh", "/data/local/bin/tcpdump.sh").start();            
              synchronized(process1){
                 process1.wait();
               }
           }
           catch (Exception e)
           {
              Log.e("Tcpdump function error", "Unable to capture the packets into the buffer");
           }
           return null;
        }
  
        /* (non-Javadoc)
         * @see android.os.AsyncTask#onPostExecute(java.lang.Object)
         */
        @Override
        protected void onPostExecute(String result)
        {
           try
           {  
              StringBuffer output = new StringBuffer();
              File file = new File("/data/local/bin/dump.txt");
              BufferedReader br = new BufferedReader(new FileReader(file), 8 * 1024);
              String line;
              while ((line = br.readLine()) != null)
              {
                 output.append(line + "\n");
              }
              tv.setText(output);
              setContentView(tv);
           }
           catch (Exception e)
           {
              e.printStackTrace();
           }
        }
  
        /* (non-Javadoc)
        * @see android.os.AsyncTask#onProgressUpdate(Progress[])
        */
       @Override
       protected void onProgressUpdate(Void... values)
        {
  
        }
  }
  </code></pre>
  
  <p>The tcpdump.sh has this line
  tcpdump -c 10 > /data/local/bin/dump.txt</p>