com.sun.jini.thread
Class NewThreadAction

java.lang.Object
  extended by com.sun.jini.thread.NewThreadAction
All Implemented Interfaces:
PrivilegedAction

public final class NewThreadAction
extends Object
implements PrivilegedAction

A PrivilegedAction for creating a new thread conveniently with an AccessController.doPrivileged or Security.doPrivileged. All constructors allow the choice of the Runnable for the new thread to execute, the name of the new thread (which will be prefixed with the constant NAME_PREFIX), and whether or not it will be a daemon thread. The new thread may be created in the system thread group (the root of the thread group tree) or an internally created non-system thread group, as specified at construction of this class. The new thread will have the system class loader as its initial context class loader (that is, its context class loader will NOT be inherited from the current thread).

Author:
Sun Microsystems, Inc.

Field Summary
private  boolean daemon
           
private static Permission getClassLoaderPermission
           
private  ThreadGroup group
           
private  String name
           
(package private) static String NAME_PREFIX
           
private  Runnable runnable
           
(package private) static ThreadGroup systemThreadGroup
          cached reference to the system (root) thread group
(package private) static ThreadGroup userThreadGroup
          special child of the system thread group for running tasks that may execute user code, so that the security policy for threads in the system thread group will not apply
 
Constructor Summary
NewThreadAction(Runnable runnable, String name, boolean daemon)
          Creates an action that will create a new thread in the system thread group.
NewThreadAction(Runnable runnable, String name, boolean daemon, boolean user)
          Creates an action that will create a new thread.
NewThreadAction(ThreadGroup group, Runnable runnable, String name, boolean daemon)
           
 
Method Summary
 Object run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME_PREFIX

static final String NAME_PREFIX
See Also:
Constant Field Values

systemThreadGroup

static final ThreadGroup systemThreadGroup
cached reference to the system (root) thread group


userThreadGroup

static final ThreadGroup userThreadGroup
special child of the system thread group for running tasks that may execute user code, so that the security policy for threads in the system thread group will not apply


getClassLoaderPermission

private static final Permission getClassLoaderPermission

group

private final ThreadGroup group

runnable

private final Runnable runnable

name

private final String name

daemon

private final boolean daemon
Constructor Detail

NewThreadAction

NewThreadAction(ThreadGroup group,
                Runnable runnable,
                String name,
                boolean daemon)

NewThreadAction

public NewThreadAction(Runnable runnable,
                       String name,
                       boolean daemon)
Creates an action that will create a new thread in the system thread group.

Parameters:
runnable - the Runnable for the new thread to execute
name - the name of the new thread
daemon - if true, new thread will be a daemon thread; if false, new thread will not be a daemon thread

NewThreadAction

public NewThreadAction(Runnable runnable,
                       String name,
                       boolean daemon,
                       boolean user)
Creates an action that will create a new thread.

Parameters:
runnable - the Runnable for the new thread to execute
name - the name of the new thread
daemon - if true, new thread will be a daemon thread; if false, new thread will not be a daemon thread
user - if true, thread will be created in a non-system thread group; if false, thread will be created in the system thread group
Method Detail

run

public Object run()
Specified by:
run in interface PrivilegedAction


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.