public class 线程组创建 {
public static void main(String[] args) {
ThreadGroup threadGroup=new ThreadGroup("my");
threadGroup.setMaxPriority(5);
System.out.println(threadGroup.getMaxPriority());
//getMaxPriority() 可以通过这个函数 知道这个线程组的最大长度
Thread t1=new Thread(threadGroup, new Runnable() {
public void run() {
System.out.println("线程组 子线程1");
}
},"T1");
Thread t2=new Thread(threadGroup, new Runnable() {
public void run() {
System.out.println("线程组 子线程2");
}
},"T2");
t1.start();
t2.start();
System.out.println(threadGroup.activeCount());
System.out.println(threadGroup.activeGroupCount());
System.out.println("-----------");
threadGroup.list();
}
}