Starting one thread at the end of another
<p>I have an application in which i have 3-4 threads , i want that 2nd thread must start when 1st thread ends , 3rd when 2nd ends and so on.. I am giving the code..</p>

<pre><code>//1st thread

new Thread(new Runnable() {


                int progressStatus = 0;

                public void run() {

                        progressStatus = dofirstWork();
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }

                        // Update the progress bar
                        handler.post(new Runnable() {
                            public void run() {
                                bar.setProgress(progressStatus);

                            }
                        });

                }
                private int dofirstWork() {


                    //do some work
                    return 25;

                 }

                }).start();         
                    //2nd thread

new Thread(new Runnable() {


                int progressStatus = 0;

                public void run() {

                        progressStatus = dosecondWork();
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }

                        // Update the progress bar
                        handler.post(new Runnable() {
                            public void run() {
                                bar.setProgress(progressStatus);

                            }
                        });

                }
                private int dosecondWork() {


                    //do some work
                    return 50;

                 }

                }).start();   

                    //3rd thread

new Thread(new Runnable() {


                int progressStatus = 0;

                public void run() {

                        progressStatus = dothirdWork();
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }

                        // Update the progress bar
                        handler.post(new Runnable() {
                            public void run() {
                                bar.setProgress(progressStatus);

                            }
                        });

                }
                private int dothirdWork() {


                    //do some work
                    return 75;

                 }

                }).start();   
</code></pre>

<p>Actually , i m trying to display progress bar at 25% for 1st function call, at 50 % for second operation and so .. on.. plz help</p>
