ThreadGroup: getName() : ThreadGroup « java.lang « Java by API






ThreadGroup: getName()

 
public class Main {
  public static void main(String[] args) {
    ThreadGroup tg = new ThreadGroup("My ThreadGroup");

    MyThread mt = new MyThread(tg, "My Thread");
    mt.start();
  }
}

class MyThread extends Thread {
  MyThread(ThreadGroup tg, String name) {
    super(tg, name);
  }

  public void run() {
    ThreadGroup tg = getThreadGroup();
    System.out.println(tg.getName());
  }
}

   
  








Related examples in the same category

1.new ThreadGroup(String groupName)
2.ThreadGroup: activeCount()
3.ThreadGroup: activeGroupCount()
4.ThreadGroup: enumerate(Thread[] thread)
5.ThreadGroup: getParent()
6.ThreadGroup: list()