Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
JBossThread(Runnable target)
Construct a new instance.
|
JBossThread(Runnable target,
String name)
Construct a new instance.
|
JBossThread(ThreadGroup group,
Runnable target)
Construct a new instance.
|
JBossThread(ThreadGroup group,
Runnable target,
String name)
Construct a new instance.
|
JBossThread(ThreadGroup group,
Runnable target,
String name,
long stackSize)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
static <T,U,E extends Exception> |
acceptInterruptDeferredEx(org.wildfly.common.function.ExceptionBiConsumer<T,U,E> consumer,
T param1,
U param2) |
static <T,E extends Exception> |
acceptInterruptDeferredEx(org.wildfly.common.function.ExceptionConsumer<T,E> consumer,
T param) |
static <T,E extends Exception> |
acceptInterruptDeferredEx(org.wildfly.common.function.ExceptionObjIntConsumer<T,E> consumer,
T param1,
int param2) |
static <T,E extends Exception> |
acceptInterruptDeferredEx(org.wildfly.common.function.ExceptionObjLongConsumer<T,E> consumer,
T param1,
long param2) |
static <T,U,E extends Exception> |
acceptInterruptResumedEx(org.wildfly.common.function.ExceptionBiConsumer<T,U,E> consumer,
T param1,
U param2) |
static <T,E extends Exception> |
acceptInterruptResumedEx(org.wildfly.common.function.ExceptionConsumer<T,E> consumer,
T param) |
static <T,E extends Exception> |
acceptInterruptResumedEx(org.wildfly.common.function.ExceptionObjIntConsumer<T,E> consumer,
T param1,
int param2) |
static <T,E extends Exception> |
acceptInterruptResumedEx(org.wildfly.common.function.ExceptionObjLongConsumer<T,E> consumer,
T param1,
long param2) |
static <T,U,E extends Exception> |
acceptWithInterruptHandler(InterruptHandler interruptHandler,
org.wildfly.common.function.ExceptionBiConsumer<T,U,E> function,
T param1,
U param2) |
static <T,E extends Exception> |
acceptWithInterruptHandler(InterruptHandler interruptHandler,
org.wildfly.common.function.ExceptionConsumer<T,E> function,
T param1) |
static <T,E extends Exception> |
acceptWithInterruptHandler(InterruptHandler interruptHandler,
org.wildfly.common.function.ExceptionObjIntConsumer<T,E> function,
T param1,
int param2) |
static <T,E extends Exception> |
acceptWithInterruptHandler(InterruptHandler interruptHandler,
org.wildfly.common.function.ExceptionObjLongConsumer<T,E> function,
T param1,
long param2) |
static <T,U,R,E extends Exception> |
applyInterruptDeferredEx(org.wildfly.common.function.ExceptionBiFunction<T,U,R,E> function,
T param1,
U param2) |
static <T,R,E extends Exception> |
applyInterruptDeferredEx(org.wildfly.common.function.ExceptionFunction<T,R,E> function,
T param) |
static <T,U,R,E extends Exception> |
applyInterruptResumedEx(org.wildfly.common.function.ExceptionBiFunction<T,U,R,E> function,
T param1,
U param2) |
static <T,R,E extends Exception> |
applyInterruptResumedEx(org.wildfly.common.function.ExceptionFunction<T,R,E> function,
T param) |
static <T,U,R,E extends Exception> |
applyWithInterruptHandler(InterruptHandler interruptHandler,
org.wildfly.common.function.ExceptionBiFunction<T,U,R,E> function,
T param1,
U param2) |
static <T,R,E extends Exception> |
applyWithInterruptHandler(InterruptHandler interruptHandler,
org.wildfly.common.function.ExceptionFunction<T,R,E> function,
T param1) |
static JBossThread |
currentThread()
Get the current
JBossThread , or null if the current thread is not a JBossThread . |
static <T> T |
executeWithInterruptDeferred(Callable<T> action)
Defer interrupts for the duration of some task.
|
static void |
executeWithInterruptDeferred(DirectExecutor directExecutor,
Runnable task)
Defer interrupts for the duration of some task.
|
static <T> T |
executeWithInterruptDeferred(PrivilegedAction<T> action)
Defer interrupts for the duration of some task.
|
static <T> T |
executeWithInterruptDeferred(PrivilegedExceptionAction<T> action)
Defer interrupts for the duration of some task.
|
static void |
executeWithInterruptDeferred(Runnable task)
Defer interrupts for the duration of some task.
|
static InterruptHandler |
getAndSetInterruptHandler(InterruptHandler newInterruptHandler)
Swap the current thread's active interrupt handler.
|
static <T,E extends Exception> |
getInterruptDeferredEx(org.wildfly.common.function.ExceptionSupplier<T,E> supplier) |
static <T,E extends Exception> |
getInterruptResumedEx(org.wildfly.common.function.ExceptionSupplier<T,E> supplier) |
static <R,E extends Exception> |
getWithInterruptHandler(InterruptHandler interruptHandler,
org.wildfly.common.function.ExceptionSupplier<R,E> function) |
void |
interrupt()
Interrupt this thread.
|
boolean |
isInterrupted() |
static boolean |
onExit(Runnable hook)
Register a runnable task to be executed when the current thread exits.
|
void |
run()
Execute the thread's
Runnable . |
static <E extends Exception> |
runInterruptDeferredEx(org.wildfly.common.function.ExceptionRunnable<E> runnable) |
static <E extends Exception> |
runInterruptResumedEx(org.wildfly.common.function.ExceptionRunnable<E> runnable) |
static <E extends Exception> |
runWithInterruptHandler(InterruptHandler interruptHandler,
org.wildfly.common.function.ExceptionRunnable<E> function) |
void |
setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh)
Change the uncaught exception handler for this thread.
|
void |
start()
Start the thread.
|
activeCount, checkAccess, clone, countStackFrames, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, sleep, sleep, stop, stop, suspend, toString, yield
public JBossThread(Runnable target)
target
- the runnable targetThread(Runnable)
public JBossThread(Runnable target, String name)
target
- the runnable targetname
- the initial thread nameThread(Runnable, String)
public JBossThread(ThreadGroup group, Runnable target) throws SecurityException
group
- the parent thread grouptarget
- the runnable targetSecurityException
- if the current thread cannot create a thread in the specified thread groupThread(ThreadGroup, Runnable)
public JBossThread(ThreadGroup group, Runnable target, String name) throws SecurityException
group
- the parent thread grouptarget
- the runnable targetname
- the initial thread nameSecurityException
- if the current thread cannot create a thread in the specified thread groupThread(ThreadGroup,Runnable,String)
public JBossThread(ThreadGroup group, Runnable target, String name, long stackSize) throws SecurityException
group
- the parent thread grouptarget
- the runnable targetname
- the initial thread nameSecurityException
- if the current thread cannot create a thread in the specified thread groupThread(ThreadGroup,Runnable,String,long)
public void interrupt()
public boolean isInterrupted()
isInterrupted
in class Thread
public static void executeWithInterruptDeferred(Runnable task)
JBossThread
, the task is simply run as-is.task
- the task to runpublic static void executeWithInterruptDeferred(DirectExecutor directExecutor, Runnable task)
JBossThread
, the task is simply run as-is.directExecutor
- the task executor to usetask
- the task to runpublic static <T> T executeWithInterruptDeferred(Callable<T> action) throws Exception
JBossThread
, the task is simply run as-is.T
- the callable's return typeaction
- the task to runException
- if the action throws an exceptionpublic static <T> T executeWithInterruptDeferred(PrivilegedAction<T> action)
JBossThread
, the task is simply run as-is.T
- the action's return typeaction
- the task to runpublic static <T> T executeWithInterruptDeferred(PrivilegedExceptionAction<T> action) throws Exception
JBossThread
, the task is simply run as-is.T
- the action's return typeaction
- the task to runException
- if the action throws an exceptionpublic static <T,U,R,E extends Exception> R applyInterruptDeferredEx(org.wildfly.common.function.ExceptionBiFunction<T,U,R,E> function, T param1, U param2) throws E extends Exception
E extends Exception
public static <T,R,E extends Exception> R applyInterruptDeferredEx(org.wildfly.common.function.ExceptionFunction<T,R,E> function, T param) throws E extends Exception
E extends Exception
public static <T,E extends Exception> T getInterruptDeferredEx(org.wildfly.common.function.ExceptionSupplier<T,E> supplier) throws E extends Exception
E extends Exception
public static <T,E extends Exception> void acceptInterruptDeferredEx(org.wildfly.common.function.ExceptionObjLongConsumer<T,E> consumer, T param1, long param2) throws E extends Exception
E extends Exception
public static <T,E extends Exception> void acceptInterruptDeferredEx(org.wildfly.common.function.ExceptionObjIntConsumer<T,E> consumer, T param1, int param2) throws E extends Exception
E extends Exception
public static <T,U,E extends Exception> void acceptInterruptDeferredEx(org.wildfly.common.function.ExceptionBiConsumer<T,U,E> consumer, T param1, U param2) throws E extends Exception
E extends Exception
public static <T,E extends Exception> void acceptInterruptDeferredEx(org.wildfly.common.function.ExceptionConsumer<T,E> consumer, T param) throws E extends Exception
E extends Exception
public static <E extends Exception> void runInterruptDeferredEx(org.wildfly.common.function.ExceptionRunnable<E> runnable) throws E extends Exception
E extends Exception
public static <T,U,R,E extends Exception> R applyInterruptResumedEx(org.wildfly.common.function.ExceptionBiFunction<T,U,R,E> function, T param1, U param2) throws E extends Exception
E extends Exception
public static <T,R,E extends Exception> R applyInterruptResumedEx(org.wildfly.common.function.ExceptionFunction<T,R,E> function, T param) throws E extends Exception
E extends Exception
public static <T,E extends Exception> T getInterruptResumedEx(org.wildfly.common.function.ExceptionSupplier<T,E> supplier) throws E extends Exception
E extends Exception
public static <T,E extends Exception> void acceptInterruptResumedEx(org.wildfly.common.function.ExceptionObjLongConsumer<T,E> consumer, T param1, long param2) throws E extends Exception
E extends Exception
public static <T,E extends Exception> void acceptInterruptResumedEx(org.wildfly.common.function.ExceptionObjIntConsumer<T,E> consumer, T param1, int param2) throws E extends Exception
E extends Exception
public static <T,U,E extends Exception> void acceptInterruptResumedEx(org.wildfly.common.function.ExceptionBiConsumer<T,U,E> consumer, T param1, U param2) throws E extends Exception
E extends Exception
public static <T,E extends Exception> void acceptInterruptResumedEx(org.wildfly.common.function.ExceptionConsumer<T,E> consumer, T param) throws E extends Exception
E extends Exception
public static <E extends Exception> void runInterruptResumedEx(org.wildfly.common.function.ExceptionRunnable<E> runnable) throws E extends Exception
E extends Exception
public void run()
Runnable
. Logs a trace message at the start and end of execution and runs exit
handlers when the thread exits.public static boolean onExit(Runnable hook) throws SecurityException
hook
- the task to runtrue
if the task was registered; false
if the task is null
or if the current
thread is not an instance of JBossThread
SecurityException
- if a security manager is installed and the caller's security context lacks the
modifyThread
RuntimePermission
public static JBossThread currentThread()
JBossThread
, or null
if the current thread is not a JBossThread
.null
public void start()
start
in class Thread
IllegalThreadStateException
- if the thread was already started.public void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh)
setUncaughtExceptionHandler
in class Thread
eh
- the new handlerpublic static InterruptHandler getAndSetInterruptHandler(InterruptHandler newInterruptHandler)
finally
block like this:
InterruptHandler oldHandler = JBossThread.getAndSetInterruptHandler(newHandler); try { ...execute interrupt-sensitive operation... } finally { JBossThread.getAndSetInterruptHandler(oldHandler); }
newInterruptHandler
- the new interrupt handlerpublic static <T,U,R,E extends Exception> R applyWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionBiFunction<T,U,R,E> function, T param1, U param2) throws E extends Exception
E extends Exception
public static <T,R,E extends Exception> R applyWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionFunction<T,R,E> function, T param1) throws E extends Exception
E extends Exception
public static <R,E extends Exception> R getWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionSupplier<R,E> function) throws E extends Exception
E extends Exception
public static <T,E extends Exception> void acceptWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionObjLongConsumer<T,E> function, T param1, long param2) throws E extends Exception
E extends Exception
public static <T,E extends Exception> void acceptWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionObjIntConsumer<T,E> function, T param1, int param2) throws E extends Exception
E extends Exception
public static <T,U,E extends Exception> void acceptWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionBiConsumer<T,U,E> function, T param1, U param2) throws E extends Exception
E extends Exception
public static <T,E extends Exception> void acceptWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionConsumer<T,E> function, T param1) throws E extends Exception
E extends Exception
public static <E extends Exception> void runWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionRunnable<E> function) throws E extends Exception
E extends Exception
Copyright © 2023 JBoss by Red Hat. All rights reserved.