Java ThreadGroup activeGroupCount() 方法

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

ThreadGroup 类的 activeGroupCount() 方法返回此线程组及其子线程组中活动线程组数量的估计值。由于在遍历内部数据结构时线程组的数量可能会动态变化,因此返回值仅为估计值。

语法

返回

它返回以当前线程组为祖先的活动线程组的数量。

示例

输出

Thread-1 starts
Number of active thread group: 2
Thread-1 completed executing