Java ThreadGroup.getMaxPriority()

Syntax

ThreadGroup.getMaxPriority() has the following syntax.

public final int getMaxPriority()

Example

In the following code shows how to use ThreadGroup.getMaxPriority() method.


// ww  w . j  a  va  2 s. co m
public class Main {

  public static void main(String[] args) {
    ThreadGroupDemo tg = new ThreadGroupDemo();
  }
}

class ThreadGroupDemo implements Runnable {
  public ThreadGroupDemo() {
    ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup");

    ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup");

    int i = pGroup.getMaxPriority();
    System.out.println("Maximum priority of ParentThreadGroup =" + i);

    Thread t1 = new Thread(pGroup, this);
    System.out.println("Starting " + t1.getName());
    t1.start();

    Thread t2 = new Thread(cGroup, this);
    System.out.println("Starting " + t2.getName());
    t2.start();

  }

  public void run() {

    System.out.println(Thread.currentThread().getName()
        + " finished executing.");
  }
}




















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