Following are the methods available in ThreadGroup in Java.
String getName()
This method returns the name of the Thread group.
int getMaxPriority();
This method returns the max priority of the Thread group.
void setMaxPriority( int pri )
This method is used to set the maximum priority of the Thread group. The default max priority is 10. The thread in ThreadGroup that already have higher priority could not be affected but for newly added Thread this method is applicable.
ThreadGroup getParent()
This method returns the parent group of the current Thread.
void list()
This method prints information about ThreadGroup in the console.
int activeCount()
This method returns several active groups present in the current Thread group.
int enumerate(Thread[] t)
This method is used to copy all active threads of the current thread group into provided thread array.
int enumerate( ThreadGroup[] list )
This method is used to copy all active sub-thread groups into the ThreadGroup array.
void interrupt()
This method is used to interrupt all waiting or sleeping thread present in the ThreadGroup.
Similar Java Tutorials
- Odd Even in Java
- Method to print exception information in Java
- Exception Handling by Using try-catch in Java
- Checked Exception vs Unchecked Exception
- Exception Hierarchy in Java
- Java Exception Handling Interview Questions
- final finally finalize in java
- User Defined Exception in Java
- Exception Handling Keyword in Java
- throw throws in Java
- try with multiple catch block in Java
- Threads in Java
- Thread priority in Java
- Threads communication in Java
- Daemon Thread in Java
1 thought on “ThreadGroup methods in Java”