On Sat, Dec 19, 2009 at 5:51 AM, Hunter Peress <[email protected]> wrote:

> aSyncTask1.getAsyncTask2().getAsyncTask3().cancel(true);
>
> The true means mayInterruptIfRunning
>
> but, lo and behold, the NDK process is still running. I don't care how
> its done, but I need that NDK process to die when I ask it to. I'm
> thinking about kill-9 it through a popen call..
>

(1) There is no "NDK process".  It is just a Java/POSIX/Linux thread, in
your OWN process, which has called down into your native code.  If you don't
supply a way for that native code to find out it should terminate early and
cleanly exit, it isn't going to do so.  This is your responsibility.

(2) Killing a -thread- is utterly, completely broken.  What if that thread
happened to be down in the memory allocator with its lock held when you did
this?  Oops, you just hosed your entire process.

(3) mayInterruptIfRunning == calling interrupt() on the thread.  This is a
Java concept.  If your native thread is not doing anything to check for this
Java state, and back out of its operation when found, then it will not do
anything.  (Actually that largely holds true for Java as well.)

(4) There is really nothing special about Android in this stuff.  It is
important to understand standard Java threading, and/or POSIX threads and
use best practices for those.  For example, AsyncTask sits on top of
FutureTask (from the standard Java library) for its core implementation.

-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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

Reply via email to