title: best strategy for attaching arbitrary threads to Android JVM
body: <p>I find myself needing to call back into the JVM from arbitrary native 
  threads that may or may not be long-lived.  It's easy enough call 
  AttachCurrentThread prior to every Java method invocation on the 
  assumption that it's a (presumably fast) no op if the thread's already 
  attached, but I find myself wondering what the JVM does with attached 
  native threads when they go away somewhere in native-land without 
  being officially detached.  Or in other words, is this going to be a 
  problem?  If so, then I find myself wondering about the overhead of 
  attaching/detaching for each Java method invocation.  Ideally each 
  thread would just register itself upon startup and detach on shutdown 
  but again, I'm writing code that must be callable from arbitrary 
  threads running code that has no idea it's running inside of Android, 
  so that's not a realistic option in this case. </p>
  
  <p>Any thoughts on the matter?</p>