public final void destroy():
Destroys this thread group and all of its subgroups. This thread group must be empty, indicating that all threads that had been in this thread group have since stopped.
First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.
public int activeGroupCount():
The value returned is only an estimate because the number of thread groups may change dynamically while this method traverses internal data structures. This method is intended primarily for debugging and monitoring purposes.
public final void checkAccess():
If there is a security manager, its checkAccess method is called with this thread group as its argument. This may result in throwing a SecurityException.
public final void setMaxPriority(int pri):
Sets the maximum priority of the group. Threads in the thread group that already have a higher priority are not affected.
First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.
If the pri argument is less than Thread.MIN_PRIORITY or greater than Thread.MAX_PRIORITY, the maximum priority of the group remains unchanged.
Otherwise, the priority of this ThreadGroup object is set to the smaller of the specified pri and the maximum permitted priority of the parent of this thread group. (If this thread group is the system thread group, which has no parent, then its maximum priority is simply set to pri.) Then this method is called recursively, with pri as its argument, for every thread group that belongs to this thread group.
本文详细介绍了 Java 中 ThreadGroup 类的几个关键方法:destroy() 用于销毁线程组及其所有子组;activeGroupCount() 估计当前线程组及其子组中的活动线程组数量;checkAccess() 检查当前运行的线程是否有权限修改线程组;setMaxPriority() 设置线程组的最大优先级。
1371

被折叠的 条评论
为什么被折叠?



