Javatpoint Logo
Javatpoint Logo

Java ThreadGroup parentOf() method

The parentOf() method of ThreadGroup class tests if the thread group is either the argument of thread group or one of its ancestor thread groups.

Syntax

Parameter

g: It is the thread group

Return

It returns true if the invoking thread is the parent of group. Otherwise, it returns false.

Example

Test it Now

Output:

Thread-1 starts
Thread-2 starts
Child thread is the parent of Parent thread: false
Parent thread is the parent of Child thread: true
Thread-1 completed executing
Thread-2 completed executing






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