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




















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable