Example usage for java.lang ThreadGroup checkAccess

List of usage examples for java.lang ThreadGroup checkAccess

Introduction

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

Prototype

public final void checkAccess() 

Source Link

Document

Determines if the currently running thread has permission to modify this thread group.

Usage

From source file:Main.java

public ThreadGroupDemo() {
    try {//from   w w  w  .  j  a va 2s.  c  o  m
        ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup");

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

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

        pGroup.checkAccess();
        System.out.println(pGroup.getName() + " has access");
        cGroup.checkAccess();
        System.out.println(cGroup.getName() + " has access");
    } catch (Exception ex) {
        System.out.println(ex.toString());
    }
}