public final class JBossExecutors extends Object
| Modifier and Type | Method | Description |
|---|---|---|
static RejectedExecutionHandler |
abortPolicy() |
Get the abort policy for a
ThreadPoolExecutor. |
static RejectedExecutionHandler |
callerRunsPolicy() |
Get the caller-runs policy for a
ThreadPoolExecutor. |
static Runnable |
classLoaderPreservingTask(Runnable delegate) |
Create a task that delegates to the given task, preserving the context classloader which was in effect when
this method was invoked.
|
static Executor |
contextClassLoaderExecutor(Executor delegate,
ClassLoader taskClassLoader) |
Create an executor which runs tasks with the given context class loader.
|
static Runnable |
contextClassLoaderResetter() |
Get a
Runnable which, when executed, clears the thread context class loader (if the caller has sufficient
privileges). |
static Executor |
directExecutor() |
Get the direct executor.
|
static Executor |
discardingExecutor() |
Get the discarding executor.
|
static ExecutorService |
discardingExecutorService() |
Get the discarding executor service.
|
static RejectedExecutionHandler |
discardOldestPolicy() |
Get the discard-oldest policy for a
ThreadPoolExecutor. |
static RejectedExecutionHandler |
discardPolicy() |
Get the discard policy for a
ThreadPoolExecutor. |
static RejectedExecutionHandler |
handoffPolicy(Executor target) |
Get a handoff policy for a
ThreadPoolExecutor. |
static Thread.UncaughtExceptionHandler |
loggingExceptionHandler() |
Get an uncaught exception handler which logs to the default error logger.
|
static Thread.UncaughtExceptionHandler |
loggingExceptionHandler(String categoryName) |
Get an uncaught exception handler which logs to the given logger.
|
static Thread.UncaughtExceptionHandler |
loggingExceptionHandler(org.jboss.logging.Logger log) |
Get an uncaught exception handler which logs to the given logger.
|
static Runnable |
nullRunnable() |
Get the null runnable which does nothing.
|
static ExecutorService |
protectedExecutorService(Executor target) |
Wrap an executor with an
ExecutorService instance which supports all the features of ExecutorService
except for shutting down the executor. |
static ScheduledExecutorService |
protectedScheduledExecutorService(ScheduledExecutorService target) |
Wrap a scheduled executor with a
ScheduledExecutorService instance which supports all the features of
ScheduledExecutorService except for shutting down the executor. |
static Executor |
rejectingExecutor() |
Get the rejecting executor.
|
static Executor |
rejectingExecutor(String message) |
Get a rejecting executor.
|
static ExecutorService |
rejectingExecutorService() |
Get the rejecting executor service.
|
static ExecutorService |
rejectingExecutorService(String message) |
Get the rejecting executor service.
|
static ThreadFactory |
resettingThreadFactory(ThreadFactory delegate) |
Create a thread factory which resets all thread-local storage and delegates to the given thread factory.
|
public static Executor directExecutor()
public static Executor rejectingExecutor()
public static Executor rejectingExecutor(String message)
message - the reject messagepublic static ExecutorService rejectingExecutorService()
public static ExecutorService rejectingExecutorService(String message)
message - the reject messagepublic static Executor discardingExecutor()
public static ExecutorService discardingExecutorService()
public static Executor contextClassLoaderExecutor(Executor delegate, ClassLoader taskClassLoader)
delegate - the executor to delegate totaskClassLoader - the context class loader to usepublic static RejectedExecutionHandler abortPolicy()
ThreadPoolExecutor.ThreadPoolExecutor.AbortPolicypublic static RejectedExecutionHandler callerRunsPolicy()
ThreadPoolExecutor.ThreadPoolExecutor.CallerRunsPolicypublic static RejectedExecutionHandler discardOldestPolicy()
ThreadPoolExecutor.ThreadPoolExecutor.DiscardOldestPolicypublic static RejectedExecutionHandler discardPolicy()
ThreadPoolExecutor.ThreadPoolExecutor.DiscardPolicypublic static RejectedExecutionHandler handoffPolicy(Executor target)
ThreadPoolExecutor. The returned instance will
delegate to another executor in the event that the task is rejected.target - the target executorpublic static ExecutorService protectedExecutorService(Executor target)
ExecutorService instance which supports all the features of ExecutorService
except for shutting down the executor.target - the target executorpublic static ScheduledExecutorService protectedScheduledExecutorService(ScheduledExecutorService target)
ScheduledExecutorService instance which supports all the features of
ScheduledExecutorService except for shutting down the executor.target - the target executorpublic static ThreadFactory resettingThreadFactory(ThreadFactory delegate) throws SecurityException
RuntimePermission("modifyThread") permission to use this method.delegate - the delegate thread factorySecurityException - if the caller does not have the RuntimePermission("modifyThread")
permissionpublic static Runnable nullRunnable()
public static Runnable contextClassLoaderResetter()
Runnable which, when executed, clears the thread context class loader (if the caller has sufficient
privileges).public static Runnable classLoaderPreservingTask(Runnable delegate) throws SecurityException
delegate - the delegate runnableSecurityException - if a security manager exists and the caller does not have the "copyClassLoader"
RuntimePermission.public static Thread.UncaughtExceptionHandler loggingExceptionHandler(org.jboss.logging.Logger log)
log - the loggerpublic static Thread.UncaughtExceptionHandler loggingExceptionHandler(String categoryName)
categoryName - the name of the logger category to log topublic static Thread.UncaughtExceptionHandler loggingExceptionHandler()
Copyright © 2018 JBoss by Red Hat. All rights reserved.