Java ThreadGroup checkAccess() 方法

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

activeCount() 方法是 ThreadGroup 类的一个方法,用于确定当前运行的线程是否有权限修改该线程组。

语法

返回

它不返回任何值。

Exception

SecurityException:如果当前线程不允许访问线程组,则会抛出此异常。

示例

输出

Parent thread has access
child thread has access
Thread-1 finished executing
Thread-2 finished executing