Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

edu.emory.mathcs.util.concurrent
Class PlainThreadFactory  view PlainThreadFactory download PlainThreadFactory.java

java.lang.Object
  extended byedu.emory.mathcs.util.concurrent.PlainThreadFactory
All Implemented Interfaces:
ThreadFactory

public class PlainThreadFactory
extends java.lang.Object
implements ThreadFactory

Thread factory implementation that attempts to ensure that created threads are equivalent regardless of threads that request creation. Precisely, created threads belong to the same thread group, and they inherit a "parent thread context" (access control context, DelegatableThreadLocals, etc.) from the factory creator rather than from the invoker of newThread(java.lang.Runnable) 55 .

This thread factory is used as a default for PooledExecutor, as it guarantees deterministic behavior and minimal security properties. Nevertheless, stronger semantics are often neccessary in security-sensitive applications. In particular, it may be required that worker tasks run within access control context and with delegatable locals of the thread that scheduled the task, which may generally be distinct from both the thread pool creator and the worker thread creator. If such security semantics is needed, use SecurePooledExecutor.

Version:
1.0

Field Summary
(package private)  java.security.AccessControlContext acc
           
(package private)  java.lang.ThreadGroup group
           
(package private)  int idx
           
(package private)  java.lang.String name
           
(package private)  ThreadContext tc
           
 
Constructor Summary
PlainThreadFactory()
          Creates a new tread factory that creates threads within a default thread group.
PlainThreadFactory(java.lang.String name)
          Creates a new tread factory that uses default thread group and specified thread name prefix.
PlainThreadFactory(java.lang.ThreadGroup group)
          Creates a new tread factory that creates threads within the specified thread group.
PlainThreadFactory(java.lang.ThreadGroup group, java.lang.String name)
          Creates a new tread factory that creates threads within the specified thread group, and uses specified thread name prefix.
 
Method Summary
private  int getNextIdx()
           
 java.lang.Thread newThread(java.lang.Runnable command)
          Create a new thread that will run the given command when started
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

acc

final java.security.AccessControlContext acc

group

final java.lang.ThreadGroup group

tc

final ThreadContext tc

name

final java.lang.String name

idx

int idx
Constructor Detail

PlainThreadFactory

public PlainThreadFactory()
Creates a new tread factory that creates threads within a default thread group. The group of the current thread (invoking this constructor) is used as a default unless explicitly overridden by current security manager.


PlainThreadFactory

public PlainThreadFactory(java.lang.String name)
Creates a new tread factory that uses default thread group and specified thread name prefix. The group of the current thread (invoking this constructor) is used as a default unless explicitly overridden by current security manager.


PlainThreadFactory

public PlainThreadFactory(java.lang.ThreadGroup group)
Creates a new tread factory that creates threads within the specified thread group.


PlainThreadFactory

public PlainThreadFactory(java.lang.ThreadGroup group,
                          java.lang.String name)
Creates a new tread factory that creates threads within the specified thread group, and uses specified thread name prefix.

Method Detail

newThread

public java.lang.Thread newThread(java.lang.Runnable command)
Description copied from interface: ThreadFactory
Create a new thread that will run the given command when started

Specified by:
newThread in interface ThreadFactory

getNextIdx

private int getNextIdx()