PTN
PTN

Reputation: 1692

Do threads run synchronously when calling execute() multiple times on one AsyncTask instance

So I have this bgTask class that extends AsyncTask, and I call the constructor once. But then I call bgTask.execute() inside a for loop. Do the threads run synchronously in this case? And I do use the onPostExecute method inside the class.

BgTask bgTask = new BgTask();

for (int i = 0; i < 10; i++) {
   bgTask.execute();
}

Upvotes: 0

Views: 71

Answers (1)

zec
zec

Reputation: 294

when you call execute it runs the AsyncTask immediately. If you need a group of threads to behave a certain way then I would suggest reviewing Java's Executors specifically Thread Pools.

Upvotes: 2

Related Questions