Thread[] threads = new Thread[masterGroup.activeCount()];
int numThreads = masterGroup.enumerate(threads);
for (int i = 0; i < numThreads; i++) {
ThreadModel threadModel = new ThreadModel();
threadModel.setThreadClass(threads[i].getClass().getName());
threadModel.setName(threads[i].getName());
threadModel.setPriority(threads[i].getPriority());
threadModel.setDaemon(threads[i].isDaemon());
threadModel.setInterrupted(threads[i].isInterrupted());
if (threads[i].getThreadGroup() != null) {
threadModel.setGroupName(threads[i].getThreadGroup().getName());
}
Object target = Instruments.getField(threads[i], "target");
if (target != null) {
threadModel.setRunnableClassName(target.getClass().getName());
}
ClassLoader cl = threads[i].getContextClassLoader();
if (cl != null) {
if (classLoaderMap != null) {
threadModel.setAppName((String) classLoaderMap.get(toUID(cl)));
}
threadModel.setClassLoader(toUID(cl));
}
threadList.add(threadModel);
}
return threadList;
}