Mike Yang
Mike Yang

Reputation: 2944

run only 2 AsyncTask in android (multithreading)

I have a application need to run 2 AsyncTask at the same time. but one AsyncTask is running something takes a long time, another is sql process. So I need the following functions. Is it possible to do like this? what kind of asyncTask should I use? thank you enter image description here

Upvotes: 0

Views: 284

Answers (1)

Russell Elfenbein
Russell Elfenbein

Reputation: 551

You will need to use a thread pool Executor to execute Asynctask. The default implementation uses a serial executor running on a single thread, you want parallel.

So create a ThreadPoolExeecutor and then use Asynctask's executeonExecutor instead of execute method.

Nandeesh solved it here: running parallel AsyncTask

Upvotes: 2

Related Questions