On Sat, Jul 16, 2011 at 9:35 AM, DCA <[email protected]> wrote: > Am I right in assuming that there is no way to forceably stop a > misbehaving thread within an Android application short of killing the > process that owns the thread? My problem is that I'm loading java- > based plug-ins (not ARM binaries) into my framework dynamically (using > OSGi) and running each plug-in on its own thread. My framework > configures, starts and holds a reference to each plug-in thread; > however, if a plug-in misbehaves (i.e. keeps running even when told to > stop), my framework is unable to forceably kill the thread its running > on. Deprecated Thread methods for this purpose (e.g. 'stop') are not > implemented in Android, so I seem to be left with flags and > interrupts, which can be easily ignored accidentally or on purpose.
Since you wrote the plug-ins, fix the misbehaving threads. You should not load arbitrary third-party plug-ins into your own application, due to the security issues outlined by Mr. Stratton. Beyond that, I know of no reliable way to forcibly stop a thread that refuses to cooperate. I do not know what ordinary OSGi hosts do in this case -- I'm not aware of Android threads being significantly more difficult to stop than are Java threads on regular Linux. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, One Low Price! -- 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

