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

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -