ericlee
ericlee

Reputation: 2753

Which is the right way for multithreading for android

currently i am using an activity which does asyntask to retrive a list of data from a remote database.

After retrieving under the onPostExecute, i used the method to display out the information gathered from the remote database. Is this the correct way for threading? Previosuly i used a handler in the onPostexecute so that i can intersect the ui thread for displaying information

Upvotes: 0

Views: 102

Answers (2)

Shailendra Singh Rajawat
Shailendra Singh Rajawat

Reputation: 8242

AsyncTask is efficient implementation of Haldler approach . so whenever multithreading needs to interact with UI thread use AsyncTask else follow standard java threading guidelines.

Upvotes: 2

Jason Robinson
Jason Robinson

Reputation: 31294

There's lots of ways to achieve multithreading in Android. If you need to perform some background operation then update the UI once this is complete, AsyncTasks are definitely the way to go. Keep in mind there is a thread limit. Look at this SO question for more information on thread limits.

Upvotes: 2

Related Questions