91
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
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
Next TopicMultithreading Java