How to check if a thread is finished inside a OnClickListener
<p>I have a OnClickListener, like this one:</p>

<pre><code>  submit.setOnClickListener(new OnClickListener() {
                if(connected) {

                         final ProgressDialog pd = ProgressDialog.show(this, "", "Please Wait..", true);


                         new Thread() {
                              public void run() {

                                //DOES SOME CALCULATION INSIDE HERE

                              pd.dismiss();  

                            }
                          }.start();

                         showPriceDialog(price); 
                }
                else
                    Toast.makeText(this, "No Network!", Toast.LENGTH_LONG).show();          
    });
</code></pre>

<p>How can I know that the thread is finished? I know that there is a function <code>isAlive()</code> that I can use if I construct my thread like this: <code>Thread t = new Thread(); t.isAlive();</code> But how can I know if my thread is still alive, the way I've constructed my code? I'am aware that this could be solved by using an AsyncTask. </p>
