ThreadGroupDemo1.java Source code

Java tutorial

Introduction

Here is the source code for ThreadGroupDemo1.java

Source

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