You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aggregation-platform/test/com/platform/test/testThread.java

30 lines
796 B

package com.platform.test;
import com.platform.utils.ThreadVolume;
public class testThread {
public static void main(String[] args) {
MyTestThread thj = new MyTestThread();
Thread th = new Thread(thj,"test1");
th.setDaemon(true);
th.start();
System.err.println(th.isDaemon());
ThreadGroup group = Thread.currentThread().getThreadGroup();
System.err.println(group.getName());
int size = group.activeCount();
Thread[] slackList = new Thread[size];
/* 获取根线程组的所有线程 */
int actualSize = group.enumerate( slackList );
Thread[] list = new Thread[actualSize];
System.arraycopy( slackList, 0, list, 0, actualSize );
for (Thread thread : list) {
System.err.println(thread.getName());
}
}
}