how to stop media player running inside a thread
<p>I am trying to stop a media player and get out  of my activity class whenever the stop option of the process dialog is pressed,but by using the below code i am able to getting out of my activity class but unable to stop the media player sound ,and it is running continuously  till the thread stop..</p>

<p>Please help me on this matter 
Thanx in advance..</p>

<pre><code>public class Test_Service extends Activity {

private MediaPlayer mp;
private Thread welcomeThread;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mp = MediaPlayer.create(Test_Service.this,R.raw.alarm1);


    welcomeThread=new Thread() {
      int wait = 0;
            @Override
        public void run() {
            try {
                super.run();
                    while (wait &lt;30000) {

                     mp.start();
                     sleep(3000);
                    wait +=3000;
                    }
            } catch (Exception e) {
                System.out.println("EXc=" + e);
            } finally {

        }
        }
    };
    new AlertDialog.Builder(Test_Service.this)
    .setTitle("Alarm is running")
    .setPositiveButton("Stop",new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int whichButton) {
        mp.stop();
                    welcomeThread.stop(); 
        Test_Service.this.finish();

    }
    })
    .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int whichButton) {
        mp.stop();
        Test_Service.this.finish();


}
    })
    .create().show();
    welcomeThread.start();
        }

    }
</code></pre>
