Sunday, March 4, 2012

Re: [android-developers] Stopping a long-running thread when a service is destroyed

On Sun, Mar 4, 2012 at 8:04 AM, Romain Guidoux <romain.guidoux@gmail.com> wrote:
> In the service's onDestroy() method, I have to wait for the end of the
> worker thread, which has to wait for the queue thread.

Why do you think you "have" to do this? onDestroy() should not be
"waiting" for anything.

> I have thought about sending a shutdown signal to the queue without
> waiting for it (no join()), but if the service is garbage-collected my
> thread will be an orphan, so it is also elligible for GC.

Active threads are not eligible for GC, as they are held by the OS.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in NYC: http://marakana.com/training/android/

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate