Thank you all for the kind and enthusiastic responses; they were all very insightful to help my understanding of Android concurrency =D
In many of these responses, many spoke of threads being "*managed*" for you. This term is very vague to me because in the Ref pages for AsyncTask and Loaders, there are no mentions of how Android manages worker threads during different app lifecycles. http://developer.android.com/reference/android/os/AsyncTask.html http://developer.android.com/reference/android/content/Loader.html (Ctrl-F > "manag" > *nothing*) In the Loaders API Guide page, it says it helps manage during a "configuration change", but what kind of change constitutes a config change? (Maybe after resuming, coming back from a screen lock, change in orientation, etc?) http://developer.android.com/guide/components/loaders.html *Can you tell me what kind of "management support" AsyncTasks and Loaders have that are different from Runnables (or that Runnables lack) ?* Thank you for reading. On Wed, Mar 20, 2013 at 2:15 PM, Kristopher Micinski <krismicin...@gmail.com > wrote: > That's what I get for not reading the documentation before speaking. :-) > On Mar 20, 2013 12:59 PM, "Kristopher Micinski" <krismicin...@gmail.com> > wrote: > >> Ah that's right, forgive my comment. >> On Mar 20, 2013 12:03 PM, "Streets Of Boston" <flyingdutc...@gmail.com> >> wrote: >> >>> The onStart/onStartCommand methods of a *Service *run in the main UI >>> thread, not a background thread, >>> But an *IntentService*'s onHandleIntent method does run in a pooled >>> background thread (pool has only one thread, and subsequent Intents are >>> handled sequentially). >>> >>> >>> On Wednesday, March 20, 2013 11:06:05 AM UTC-4, Kristopher Micinski >>> wrote: >>>> >>>> Though it's worth noting that since an `IntentService` doesn't run in >>>> a background thread context. (Probably one of the biggest things >>>> beginners screw up..) >>>> >>>> Kris >>>> >>>> On Wed, Mar 20, 2013 at 9:49 AM, Streets Of Boston >>>> <flying...@gmail.com> wrote: >>>> > There are even more ways of doing stuff in the background: >>>> IntentService :-) >>>> > >>>> > Runnable >>>> > If you mean a Thread (running itself or a Runnable): Generally, avoid >>>> using >>>> > them. But there are good use cases: When you want to setup something >>>> that >>>> > runs in the background for a long time (possible during the entire >>>> lifetime >>>> > of your app's process), simple Threads are very useful, e.g. set up a >>>> > rendering thread for an openGL game. >>>> > AsyncTasks >>>> > If you want to run something in the background, that is a one-shot >>>> > operation, relatively short duration and you want your UI (main >>>> UI-thread) >>>> > to be notified about updates/results. If you are not worried about >>>> screen >>>> > rotations/config-changes, etc., AsyncTasks work well. AsyncTasks in >>>> these >>>> > situations are relatively simple to implement. >>>> > Loaders, AsyncTaskLoaders >>>> > Like AsyncTasks, but they are well suited to easily handle screen >>>> > rotations/config-changes/etc, especially when used in conjunction >>>> with >>>> > Fragments. >>>> > IntentService >>>> > Also good for one-shot operations with relatively short duration. >>>> Best used >>>> > when you want to share these operations among other components of >>>> your or >>>> > other people's applications and/or want to have Android manage its >>>> > life-cycle (e.g. if an (Intent)Service is killed, Android could >>>> restart it >>>> > for you automatically and re-issue the Intent that started it >>>> before). >>>> > >>>> > >>>> > On Tuesday, March 19, 2013 8:33:50 PM UTC-4, littledot wrote: >>>> >> >>>> >> Android concurrency has always bugged me... >>>> >> >>>> >> These are all methods to achieve essentially the same thing: >>>> >> mutli-threading >>>> >> >>>> >> I honestly don't see much difference between them, except the amount >>>> of >>>> >> code you need to write...... >>>> >> >>>> >> >>>> >> >>>> >> Which methods do you use? >>>> >> >>>> >> Are there certain situations where you prefer one method over the >>>> other? >>>> >> >>>> >> Or do you stick to one method and use it as a rule-of-thumb? >>>> >> >>>> >> >>>> >> >>>> >> Thanks for reading. >>>> > >>>> > -- >>>> > -- >>>> > You received this message because you are subscribed to the Google >>>> > Groups "Android Developers" group. >>>> > To post to this group, send email to android-d...@**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<http://groups.google.com/group/android-developers?hl=en> >>>> > --- >>>> > You received this message because you are subscribed to the Google >>>> Groups >>>> > "Android Developers" group. >>>> > To unsubscribe from this group and stop receiving emails from it, >>>> send an >>>> > email to android-developers+**unsubscr...@googlegroups.com. >>>> > For more options, visit >>>> > https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>. >>>> >>>> > >>>> > >>>> >>> -- >>> -- >>> 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 >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "Android Developers" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to android-developers+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> -- > -- > 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 > --- > You received this message because you are subscribed to a topic in the > Google Groups "Android Developers" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/android-developers/x_7dovdXhjE/unsubscribe?hl=en > . > To unsubscribe from this group and all its topics, send an email to > android-developers+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Thank you for your time. Yours truly, Sheng-Dean Chang 章聖典 (s39ch...@uwaterloo.ca, littledot5...@gmail.com) -- -- 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 --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.