ThreadDemo.java Source code

Java tutorial

Introduction

Here is the source code for ThreadDemo.java

Source

class ThreadDemo extends Thread {

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