Android's Wait function
<p>I have a snippet of Android code, My understanding is a new thread is created in the background which starts the record function.    It waits for 10seconds
But my question how to stop the recording.   From the record function it stops when the boolean isRecording is false.     </p>

<p>My question is isRecording turns false after 10 seconds? </p>

<pre><code>   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Thread thread = new Thread(new Runnable() {
        public void run() {
            isRecording=true;
        record();              //starts to record
        } 
        });
        thread.start();   //thread start


     //=============================================//

        synchronized (this) 
        {

     try {
     wait(10000);

                  //wait for 10second
    } catch (InterruptedException e) {}
        }
    isRecording = false;   

    try {
      thread.join();  //blocks the current thread until the receiver finish execution and dies.
   } catch (InterruptedException e) {}     //interruptedException

   }
  }


   public void record() {


        short[] buffer = new short[bufferSize]; 
        audioRecord.startRecording();

        while (isRecording) {
            int bufferReadResult = audioRecord.read(buffer, 0, bufferSize);
            for (int i = 0; i &lt; bufferReadResult; i++)
            dos.writeShort(buffer[i]);
            }

        audioRecord.stop();
        dos.close();

        } catch (Throwable t) {
        Log.e("AudioRecord","Recording Failed");
        }

}
</code></pre>
