Javatpoint Logo
Javatpoint Logo

Java Thread getThreadGroup() method

The getThreadGroup() method of thread class is used to return the thread's thread group to which this thread belongs. This method returns null if this thread has died (been stopped).

Syntax

Return

This method returns the thread group of the thread.

Example

Test it Now

Output:

Thread-1 is a member of ThreadGroup
Thread-2 is a member of AnotherGroup
javatpoint
javatpoint

The above example use getThreadGroup() method of Thread class to get the object of ThreadGroup then use the getName() method to get the name of the thread group.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA