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

java - How to pass parameters between Request-Scoped Controllers? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -