Java ThreadGroup getParent() 方法

2024 年 11 月 11 日 | 阅读 1 分钟

ThreadGroup 类的 getParent() 方法返回线程组的父级。

语法

返回

此方法返回线程组的父级。

Exception

SecurityException: 如果当前线程无法修改线程组。

示例

输出

Starting Thread-1
Starting Thread-2
ParentThreadGroup for Parent thread is main
ParentThreadGroup for Child thread is Parent thread
Thread-1 completed executing
Thread-2 completed executing