ThreadGroup methods in Java

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

1 thought on “ThreadGroup methods in Java”

Leave a Comment