|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.emory.mathcs.util.concurrent.ExecutorUtils
Nested Class Summary | |
static class |
ExecutorUtils.SafeThreadFactory
Thread factory implementation that attempts to ensure that created threads are equivalent regardless of threads that request creation. |
Method Summary | |
static Future |
completedFuture(java.lang.Object result)
Creates a successfully completed future with specified result. |
static Future |
completedFuture(java.lang.Object result,
Callback cb)
Creates a successfully completed future with specified result and completion callback . |
static Callable |
delegatedCallable(Callable callable)
Returns a callable wrapper that ensures that executions (even if performed by different threads) inherit current access control context and ThreadContext . |
static Callable |
delegatedCallable(Callable callable,
ThreadContext tc)
Returns a callable wrapper that ensures that executions (even if performed by different threads) inherit current access control context and the specified ThreadContext . |
static java.lang.Runnable |
delegatedRunnable(java.lang.Runnable runnable)
Returns a runnable wrapper that ensures that executions (even if performed by different threads) inherit current access control context and ThreadContext . |
static java.lang.Runnable |
delegatedRunnable(java.lang.Runnable runnable,
ThreadContext tc)
Returns a runnable wrapper that ensures that executions (even if performed by different threads) inherit current access control context and the specified ThreadContext . |
static Future |
failedFuture(java.lang.Throwable cause)
Creates a failed future with specified failure cause. |
static Future |
failedFuture(java.lang.Throwable cause,
Callback cb)
Creates a failed future with specified failure cause and completion callback . |
static ExecutorService |
newFixedSecureThreadPool(int nThreads)
Creates a thread pool that reuses a fixed set of threads operating off a shared unbounded queue. |
static ExecutorService |
newSecureCachedThreadPool()
Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available. |
static ExecutorService |
newSecureSingleThreadExecutor()
Creates an Executor that uses a single worker thread operating off an unbounded queue. |
static ThreadFactory |
safeThreadFactory()
Returns a thread factory implementation that attempts to ensure that created threads are equivalent regardless of threads that request creation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static ExecutorService newFixedSecureThreadPool(int nThreads)
nThreads
- the number of threads in the pool
public static ExecutorService newSecureSingleThreadExecutor()
public static ExecutorService newSecureCachedThreadPool()
ThreadPoolExecutor
constructors.
public static java.lang.Runnable delegatedRunnable(java.lang.Runnable runnable)
ThreadContext
. In particular, the runnable will
always run with the same access permissions,
delegatable thread locals
,
and context class loader, determined
at the time of invocation of this method.
public static java.lang.Runnable delegatedRunnable(java.lang.Runnable runnable, ThreadContext tc)
ThreadContext
. In particular, the
runnable will always run with the same access permissions,
delegatable thread locals
,
and context class loader, determined
at the time of invocation of this method.
public static Callable delegatedCallable(Callable callable)
ThreadContext
. In particular, the callable will
always run with the same access permissions,
delegatable thread locals
,
and context class loader, determined
at the time of invocation of this method.
public static Callable delegatedCallable(Callable callable, ThreadContext tc)
ThreadContext
. In particular, the
callable will
always run with the same access permissions,
delegatable thread locals
,
and context class loader, determined
at the time of invocation of this method.
public static ThreadFactory safeThreadFactory()
DelegatableThreadLocal
s, etc.) from the invoker of this method
rather than from the invoker of ExecutorUtils.SafeThreadFactory.newThread(java.lang.Runnable)
.
Use with ThreadPoolExecutor
, to ensure
deterministic behavior and consistent 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
SecureThreadPoolExecutor
or one of "newSecure*" methods.
public static Future completedFuture(java.lang.Object result)
result
- the result of the future
public static Future completedFuture(java.lang.Object result, Callback cb)
completion callback
. If not null, the callback is
immediately notified about the completion.
result
- the result of the futurecb
- the callback to be notified about successful completion
public static Future failedFuture(java.lang.Throwable cause)
cause
- the cause of failure
public static Future failedFuture(java.lang.Throwable cause, Callback cb)
completion callback
. If not null, the callback is
immediately notified about the completion.
cause
- the cause of failurecb
- the callback to be notified about failure
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |