>>"Relying on Java thread interruption is a serious code smell IMHO, NDK or >>not"<< Hi Mark,
Why is this a code-smell? Interrupting long-running threads that 'wait ()' is perfectly fine for controlling these threads, telling them to do stuff, pause or even stop and exit. On Dec 19, 9:20 am, Mark Murphy <[email protected]> wrote: > Hunter Peress wrote: > > Hi, I'm running a pretty weird setup: > > > AsyncTask1.class -> AsyncTask2.class ->AsyncTask3 (inner class of > > AsyncTask2) ->NDK call (this one takes a long time). > > > Since the NDK takes so long, I want to give users the option to kill > > the NDK call so that they can actually use the app. Basically, I keep > > references of all the asynctask instances and I do: > > > 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.. > > > Any ideas on how to kill this thing?? > > NDK questions are best asked on the NDK Google Group: > > http://groups.google.com/group/android-ndk > > That being said, AsyncTask#cancel() will only stop a running thread if > the Java thread is interruptible, and it would not shock me if threads > tied up in NDK calls are not interruptible. Relying on Java thread > interruption is a serious code smell IMHO, NDK or not. > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://twitter.com/commonsguy > > Android Training in Germany, 18-22 January 2010:http://bignerdranch.com- Hide > quoted text - > > - Show quoted text - -- 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

