Example usage for java.lang ThreadGroup toString

List of usage examples for java.lang ThreadGroup toString

Introduction

In this page you can find the example usage for java.lang ThreadGroup toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of this Thread group.

Usage

From source file:Main.java

public static void main(String[] args) {

    ThreadGroup group = new ThreadGroup("admin");
    Thread t = new Thread(group, "website");

    System.out.println("Threadgroup = " + group.getName());

    String str = group.toString();
    System.out.println(str);//from  w w w.j  a v a 2 s.c  o m
}

From source file:Main.java

public static String getThreadTree() {
    ThreadGroup root = Thread.currentThread().getThreadGroup();
    while (root.getParent() != null) {
        root = root.getParent();//from  www .  j  a  v a 2 s  . c o m
    }
    StringBuffer buffer = new StringBuffer();

    buffer.append(root.toString()).append("\r");
    visit(root, 1, buffer);
    return buffer.toString();
}