"Managed" means that a lot of stuff is going on in the background that you 
don't have to worry about. E.g.

   - You don't have to create threads. Just subclass the 
   AsyncTask/Loader/IntentService and implement/override the correct method 
   and your code will run in some background thread.
   You don't have to manage these threads, you don't have to manage sending 
   messages from the background thread(s) to the UI thread and vice versa, 
   etc. You don't have to manage these threads, because code is already 
   implemented for you, e.g. code that creates Threads and stops them, etc. 
   Just read the documentation of AsyncTask/Loader/IntentService and you'll 
   understand a bit more.
   
   - Continuation and result-message delivery.
   A change in configuration is any change to the current state of your 
   phone that may destroy your current Activity and recreates a new instance 
   of it immediately after that. Examples are screen-rotation, keyboard slide 
   in/out, etc.
   When your phone changes configuration (e.g. screen rotation), your 
   Activity and your View hierarchy is usually destroyed (old Activity) and 
   re-created (new Activity in different orientation). If you had some 
   background processes running before the rotation and these are still 
   running after the rotation, you still want your UI to be notified of the 
   background-process' final result. Loaders (used by Fragments) make that a 
   bit easier for you (onLoadFinished callbacks when data loaded by a Loader 
   is ready). 

Note that Runnables are nothing. A Runnable is just a class that implements 
the 'public void run()' method. You probably mean Threads instead. 

On Wednesday, March 20, 2013 2:36:13 PM UTC-4, littledot wrote:
>
> 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 
> <krismi...@gmail.com<javascript:>
> > wrote:
>
>> That's what I get for not reading the documentation before speaking. :-) 
>> On Mar 20, 2013 12:59 PM, "Kristopher Micinski" 
>> <krismi...@gmail.com<javascript:>> 
>> wrote:
>>
>>> Ah that's right, forgive my comment. 
>>> On Mar 20, 2013 12:03 PM, "Streets Of Boston" 
>>> <flying...@gmail.com<javascript:>> 
>>> 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-d...@googlegroups.com<javascript:>
>>>> To unsubscribe from this group, send email to
>>>> android-developers+unsubscr...@googlegroups.com <javascript:>
>>>> 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<javascript:>
>>>> .
>>>> 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-d...@googlegroups.com<javascript:>
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com <javascript:>
>> 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 <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> Thank you for your time.
>
> Yours truly,
> Sheng-Dean Chang 章聖典
> (s39c...@uwaterloo.ca <javascript:>, little...@gmail.com <javascript:>)
>

-- 
-- 
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.


Reply via email to