| ||||
Copyright 1999 Sams Publishing |
|
Using the getThreadGroup() Method of Thread |
If you need to know which thread group a thread belongs to, you can use the getThreadGroup() method on Thread . To find out which thread group threadX belongs to, use this code: |
ThreadGroup groupForThreadX = threadX.getThreadGroup(); |
groupForThreadX is a reference to the ThreadGroup that threadX belongs to. If a thread is no longer alive , getThreadGroup() returns null instead of a ThreadGroup . |
To determine which thread group the thread executing a block of code belongs to, use: |
ThreadGroup group = Thread.currentThread().getThreadGroup(); |
| |||
Toc |