同时运行多个AsyncTask-不可能?
public class AndroidJunk extends Activity { class PrinterTask extends AsyncTask<String, Void, Void> { protected Void doInBackground(String ... x) { while (true) { System.out.println(x[0]); try { Thread.sleep(1000); } catch (InterruptedException ie) { ie.printStackTrace(); } } } }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); new PrinterTask().execute("bar bar bar"); new PrinterTask().execute("foo foo foo"); System.out.println("onCreate() is done."); }}
onCreate() is done.bar bar bar foo foo foo bar bar bar foo foo foo
onCreate() is done.bar bar bar bar bar bar bar bar bar
至尊宝的传说
蛊毒传说
相关分类