Java Data Type Tutorial - Java ThreadGroup.toString()








Syntax

ThreadGroup.toString() has the following syntax.

public String toString()

Example

In the following code shows how to use ThreadGroup.toString() method.

//  ww  w.j a v  a  2s . c o  m

public class Main {

   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);
   }
}

The code above generates the following result.