Java Thread.getThreadGroup()
Syntax
Thread.getThreadGroup() has the following syntax.
public final ThreadGroup getThreadGroup()
Example
In the following code shows how to use Thread.getThreadGroup() method.
class ThreadDemo extends Thread {
/* www . j a va 2 s. c o m*/
public void run() {
// returns the thread group to which this thread belongs
System.out.println(getThreadGroup());
}
}
public class Main {
public static void main(String[] args) {
ThreadGroup tgrp = new ThreadGroup("Thread Group");
Thread t = new Thread(tgrp, new ThreadDemo());
t.start();
}
}