Enabling and update progressbar from a thread
<p>Progressbar will not show when I try to access it from a thread nor update the progress. I would prefer to just have a progress spinner be displayed until the network activity is complete, and this network activity is just to post some text data to the server.This is the code I have so far, any help is appreciated thanks,</p>

<pre><code> Thread th = new Thread(){
        public void run() {

                     try {
                        sleep(5000);

                         while(cnt &lt; 5000){
                             activty.this.runOnUiThread(new Runnable(){
                                 public void run()
                                 {
                                     ProgressBar pd = (ProgressBar)findViewById(R.id.progressBar1);
                                    pd.setVisibility(0);
                                    pd.setMax(100);

                                     pd.setProgress(cnt);
                                    cnt += 100;
                                 }
                             });
                         }
                     } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
        }

        int cnt = 100;
    };
    th.start();
    `
</code></pre>
