Example usage for java.lang ThreadGroup getMaxPriority

List of usage examples for java.lang ThreadGroup getMaxPriority

Introduction

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

Prototype

public final int getMaxPriority() 

Source Link

Document

Returns the maximum priority of this thread group.

Usage

From source file:ThreadLister.java

/** Display info about a thread group */
private static void printGroupInfo(ThreadGroup g, String indent) {
    if (g == null)
        return;// www. ja  v a2s .  com
    int numThreads = g.activeCount();
    int numGroups = g.activeGroupCount();
    Thread[] threads = new Thread[numThreads];
    ThreadGroup[] groups = new ThreadGroup[numGroups];

    g.enumerate(threads, false);
    g.enumerate(groups, false);

    System.out.println(indent + "Thread Group: " + g.getName() + "  Max Priority: " + g.getMaxPriority()
            + (g.isDaemon() ? " Daemon" : ""));

    for (int i = 0; i < numThreads; i++)
        printThreadInfo(threads[i], indent + "    ");
    for (int i = 0; i < numGroups; i++)
        printGroupInfo(groups[i], indent + "    ");
}

From source file:ThreadLister.java

/** Display info about a thread group and its threads and groups */
private static void printGroupInfo(PrintWriter out, ThreadGroup g, String indent) {
    if (g == null)
        return;//from   w ww  . ja v a  2  s  .  com
    int num_threads = g.activeCount();
    int num_groups = g.activeGroupCount();
    Thread[] threads = new Thread[num_threads];
    ThreadGroup[] groups = new ThreadGroup[num_groups];

    g.enumerate(threads, false);
    g.enumerate(groups, false);

    out.println(indent + "Thread Group: " + g.getName() + "  Max Priority: " + g.getMaxPriority()
            + (g.isDaemon() ? " Daemon" : ""));

    for (int i = 0; i < num_threads; i++)
        printThreadInfo(out, threads[i], indent + "    ");
    for (int i = 0; i < num_groups; i++)
        printGroupInfo(out, groups[i], indent + "    ");
}

From source file:Main.java

/**
 * Display info about a thread group and its threads and groups
 *//* w  w  w  . j  ava 2  s  .c  o m*/
private static void printGroupInfo(PrintWriter out, ThreadGroup g, String indent) {
    if (g == null) {
        return;
    }
    int num_threads = g.activeCount();
    int num_groups = g.activeGroupCount();
    Thread[] threads = new Thread[num_threads];
    ThreadGroup[] groups = new ThreadGroup[num_groups];

    g.enumerate(threads, false);
    g.enumerate(groups, false);

    out.println(indent + "Thread Group: " + g.getName() + "  Max Priority: " + g.getMaxPriority()
            + (g.isDaemon() ? " Daemon" : ""));

    for (int i = 0; i < num_threads; i++) {
        printThreadInfo(out, threads[i], indent + "    ");
    }
    for (int i = 0; i < num_groups; i++) {
        printGroupInfo(out, groups[i], indent + "    ");
    }
}

From source file:Main.java

/** Collect info about a thread group */
private static void collectThreadGroupInfo(final ThreadGroup g, final StringBuffer str, final String indent) {
    if (g == null) {
        return;/*ww  w.j  a va  2  s.com*/
    }
    int numThreads = g.activeCount();
    int numGroups = g.activeGroupCount();
    final Thread[] threads = new Thread[numThreads * 2];
    final ThreadGroup[] groups = new ThreadGroup[numGroups * 2];

    numThreads = g.enumerate(threads, false);
    numGroups = g.enumerate(groups, false);

    str.append(indent).append("Thread Group: [").append(g.getName()).append("]  Max Priority: [")
            .append(g.getMaxPriority()).append(g.isDaemon() ? " Daemon" : "").append("]")
            .append(LINE_SEPARATOR);

    for (int i = 0; i < numThreads; i++) {
        if (threads[i] != null) {
            collectThreadInfo(threads[i], str, indent + "    ");
        }
    }
    for (int i = 0; i < numGroups; i++) {
        collectThreadGroupInfo(groups[i], str, indent + "    ");
    }
}

From source file:Main.java

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();/*from w w  w  .ja va 2s.  co m*/

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

}