Tuesday 4 March 2014

activeGroupCount() : Find number of subgroups

public int activeGroupCount()
Returns an estimate of the number of active groups in this thread group and its subgroups. Recursively iterates over all subgroups in this thread group. The value returned by this method is an estimate only, since groups are added and removed dynamically.

Example
class GroupCount{
 public static void main(String args[]){
  ThreadGroup group1 = new ThreadGroup("group1");
  ThreadGroup group2 = new ThreadGroup(group1, "group2");
  ThreadGroup group3 = new ThreadGroup(group2, "group3");
  ThreadGroup group4 = new ThreadGroup(group2, "group3");

  System.out.println("Active number of groups in group1 is " + group1.activeGroupCount());
  System.out.println("Active number of groups in group2 is " + group2.activeGroupCount());
  System.out.println("Active number of groups in group3 is " + group3.activeGroupCount());
  System.out.println("Active number of groups in group4 is " + group4.activeGroupCount());
 }
}
   
Output

Active number of groups in group1 is 3
Active number of groups in group2 is 2
Active number of groups in group3 is 0
Active number of groups in group4 is 0



Get parent thread group                                                 Find sub groups                                                 Home

No comments:

Post a Comment