java - Get reference to Thread Object from its ID -
java - Get reference to Thread Object from its ID -
how can reference running thread if know id associated thread?
e.g.
long threadid = 12342; thread thread = (what goes here?) getthreadfromid(threadid); //i know totally made
you have 2 ways it. both quite simple:
old way: root thread grouping may access thread.currentthread().getgroup()..getparent() in loop. , phone call enumerate(thread[])
newer (slower though). for (thread t : thread.getallstacktraces().keyset()) if (t.getid()==id)...
the first method has little problem due bug in threadgroup.destroy(), threadgroup may not enumerate @ all.
the sec slower , has security flaw, though.
java android multithreading
Comments
Post a Comment