| Author |
How Get Inactive Threads of a ThreadGroup?
|
Robert Paris
Ranch Hand
Joined: Jul 28, 2002
Posts: 585
|
|
ThreadGroup has a way to get all active threads of that thread group (enumerate). I can also get a list of the names of all active AND inactive threads (list). Does anyone know how I can actually get a reference to the inactive threads? With enumerate, I can get actual references to the thread objects: <ThreadGroup>.enumerate(Thread[] list, boolean recurse); And I know the ThreadGroup has a reference to the inactive threads as well, because list will show the inactive threads too: <ThreadGroup>.list(); Thanks!
|
 |
Robert Paris
Ranch Hand
Joined: Jul 28, 2002
Posts: 585
|
|
|
anyone? I can't find the answer anywhere, but really need to be able to do this! help!
|
 |
Robert Paris
Ranch Hand
Joined: Jul 28, 2002
Posts: 585
|
|
OK, here's how you do it: A couple things: 1. You need to set the field accessible even without a security manager 2. If you have security on, you'll need the runtime permission "suppressAccessChecks" even though I know most people run with no security or "AllPermission". 3. That check for null is important! I believe it keeps more room than it needs, so it doesn't have to expand all the time, so you don't want to hit a null pointer. Have fun!
|
 |
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
|
|
Great! Now I think that I will move this to the Threads forum .
|
"JavaRanch, where the deer and the Certified play" - David O'Meara
|
 |
 |
|
|
subject: How Get Inactive Threads of a ThreadGroup?
|
|
|