Example usage for java.lang ThreadGroup setMaxPriority

List of usage examples for java.lang ThreadGroup setMaxPriority

Introduction

In this page you can find the example usage for java.lang ThreadGroup setMaxPriority.

Prototype

public final void setMaxPriority(int pri) 

Source Link

Document

Sets the maximum priority of the group.

Usage

From source file:Main.java

public ThreadGroupDemo() {

    ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup");
    pGroup.setMaxPriority(Thread.MAX_PRIORITY - 2);

    ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup");
    cGroup.setMaxPriority(Thread.NORM_PRIORITY);

    Thread t1 = new Thread(pGroup, this);
    t1.setPriority(Thread.MAX_PRIORITY);
    System.out.println("Starting " + t1.getName());
    t1.start();//from www.  j a va2 s. co  m

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

    System.out.println("Active threads in \"" + pGroup.getName() + "\" = " + pGroup.activeCount());

}