All the answers I have seen so far are true, but yours is the most
informative. I would be a little careful about the generalization
though, that if he has to ask, then AsyncTask is the answer. AsyncTask
is not so convenient for recurring tasks, unless you are OK with
having to start it up all over again each time the trigger occurs.

And there is one other tool in Android that is still useful for
Threads, when barebones Java Threads are too much of a bother to
manage: Looper/Handler. This was the standard Android threading
'workhorse' before AsyncTask (or its unoficcial predecessor UserTask)
became so popular.

On May 7, 11:31 am, Bob Kerns <r...@acm.org> wrote:
> Use an AsyncTask -- unless both of the following are true:
>
>    - AsyncTask doesn't meet your needs somehow
>    - You know very clearly and well how to properly synchronize between
>    threads, and how to transfer work to the UI thread where needed, etc.
>
> If AsyncTask doesn't meet your needs, and you don't have the second
> requirement -- you have a very steep (and error-prone) learning curve ahead
> of you. The whole idea of AsyncTask is to make it easier to write reliable
> asynchronous code.
>
> Generally speaking -- if you have to ask, AsyncTask is probably the answer.
>
> On Saturday, May 7, 2011 8:53:29 AM UTC-7, Droid wrote:
>
> > Seems I can use an async task OR roll my own thread to do a background
> > task.
>
> > Is one better than the other?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to