class ThreadGroupDemo1 {
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());
}
}