How to avoid Multiple Async Thread calls?
<p>friends,</p>

<p>i am using following code to fill android listview asynchronously</p>

<p>now problem is while running this thread i press back button or home button and comes back to activity </p>

<p>multiple threads are started....</p>

<p>can i avoid these multiple threads
actually i want if thread is running then it should not get called again and again.
it should be called when previous thread is complete.</p>

<pre><code>private static String[] items={.......};

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        setListAdapter(
                new ArrayAdapter&lt;String&gt;(this,
                                android.R.layout.simple_list_item_1,
                                new ArrayList()));

        AddStringTask test= new AddStringTask();
        test.execute();




    }


class AddStringTask extends AsyncTask&lt;Void, String, Void&gt; {
        @Override
        protected Void doInBackground(Void... unused) {
            for (String item : items) {
                publishProgress(item);
                SystemClock.sleep(1000);
            }

            return(null);
        }

        @Override
        protected void onProgressUpdate(String... item) {
            ((ArrayAdapter)getListAdapter()).add(item[0]);

        }

        @Override
        protected void onPostExecute(Void unused) {
            Toast
                .makeText(AsyncThread.this, 
                        "Done - Finished updating Java Book List!",
                        Toast.LENGTH_SHORT)
                .show();

        }
    }
}
</code></pre>

<p>any useful solution?</p>

<p>thanks in advance. </p>
