Class JBossThread
java.lang.Object
java.lang.Thread
org.jboss.threads.JBossThread
- All Implemented Interfaces:
Runnable
A JBoss thread. Supports logging and extra operations.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionJBossThread(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. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T, U, E extends Exception>
voidacceptInterruptDeferredEx(org.wildfly.common.function.ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) Deprecated.static <T, E extends Exception>
voidacceptInterruptDeferredEx(org.wildfly.common.function.ExceptionConsumer<T, E> consumer, T param) Deprecated.static <T, E extends Exception>
voidacceptInterruptDeferredEx(org.wildfly.common.function.ExceptionObjIntConsumer<T, E> consumer, T param1, int param2) Deprecated.static <T, E extends Exception>
voidacceptInterruptDeferredEx(org.wildfly.common.function.ExceptionObjLongConsumer<T, E> consumer, T param1, long param2) Deprecated.static <T, U, E extends Exception>
voidacceptInterruptResumedEx(org.wildfly.common.function.ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) Deprecated.static <T, E extends Exception>
voidacceptInterruptResumedEx(org.wildfly.common.function.ExceptionConsumer<T, E> consumer, T param) Deprecated.static <T, E extends Exception>
voidacceptInterruptResumedEx(org.wildfly.common.function.ExceptionObjIntConsumer<T, E> consumer, T param1, int param2) Deprecated.static <T, E extends Exception>
voidacceptInterruptResumedEx(org.wildfly.common.function.ExceptionObjLongConsumer<T, E> consumer, T param1, long param2) Deprecated.static <T, U, E extends Exception>
voidacceptWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionBiConsumer<T, U, E> function, T param1, U param2) Deprecated.static <T, E extends Exception>
voidacceptWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionConsumer<T, E> function, T param1) Deprecated.static <T, E extends Exception>
voidacceptWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionObjIntConsumer<T, E> function, T param1, int param2) Deprecated.static <T, E extends Exception>
voidacceptWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionObjLongConsumer<T, E> function, T param1, long param2) Deprecated.static <T, U, R, E extends Exception>
RapplyInterruptDeferredEx(org.wildfly.common.function.ExceptionBiFunction<T, U, R, E> function, T param1, U param2) Deprecated.static <T, R, E extends Exception>
RapplyInterruptDeferredEx(org.wildfly.common.function.ExceptionFunction<T, R, E> function, T param) Deprecated.static <T, U, R, E extends Exception>
RapplyInterruptResumedEx(org.wildfly.common.function.ExceptionBiFunction<T, U, R, E> function, T param1, U param2) Deprecated.static <T, R, E extends Exception>
RapplyInterruptResumedEx(org.wildfly.common.function.ExceptionFunction<T, R, E> function, T param) Deprecated.static <T, U, R, E extends Exception>
RapplyWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionBiFunction<T, U, R, E> function, T param1, U param2) Deprecated.static <T, R, E extends Exception>
RapplyWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionFunction<T, R, E> function, T param1) Deprecated.static JBossThreadGet the currentJBossThread, ornullif the current thread is not aJBossThread.static voidDefer interrupts for the duration of some task.static <T> TexecuteWithInterruptDeferred(PrivilegedAction<T> action) Deprecated.static <T> TDeprecated.static <T> TexecuteWithInterruptDeferred(Callable<T> action) Defer interrupts for the duration of some task.static InterruptHandlergetAndSetInterruptHandler(InterruptHandler newInterruptHandler) Swap the current thread's active interrupt handler.static <T, E extends Exception>
TgetInterruptDeferredEx(org.wildfly.common.function.ExceptionSupplier<T, E> supplier) Deprecated.static <T, E extends Exception>
TgetInterruptResumedEx(org.wildfly.common.function.ExceptionSupplier<T, E> supplier) Deprecated.static <R, E extends Exception>
RgetWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionSupplier<R, E> function) Deprecated.voidInterrupt this thread.booleanstatic booleanRegister a runnable task to be executed when the current thread exits.voidrun()Execute the thread'sRunnable.static <E extends Exception>
voidrunInterruptDeferredEx(org.wildfly.common.function.ExceptionRunnable<E> runnable) Deprecated.static <E extends Exception>
voidrunInterruptResumedEx(org.wildfly.common.function.ExceptionRunnable<E> runnable) Deprecated.static <E extends Exception>
voidrunWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionRunnable<E> function) Deprecated.voidChange the uncaught exception handler for this thread.voidstart()Start the thread.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, sleep, sleep, stop, suspend, toString, yield
-
Constructor Details
-
JBossThread
Construct a new instance.- Parameters:
target- the runnable target- See Also:
-
JBossThread
-
JBossThread
Construct a new instance.- Parameters:
group- the parent thread grouptarget- the runnable target- Throws:
SecurityException- if the current thread cannot create a thread in the specified thread group- See Also:
-
JBossThread
Construct a new instance.- Parameters:
group- the parent thread grouptarget- the runnable targetname- the initial thread name- Throws:
SecurityException- if the current thread cannot create a thread in the specified thread group- See Also:
-
JBossThread
public JBossThread(ThreadGroup group, Runnable target, String name, long stackSize) throws SecurityException Construct a new instance.- Parameters:
group- the parent thread grouptarget- the runnable targetname- the initial thread name- Throws:
SecurityException- if the current thread cannot create a thread in the specified thread group- See Also:
-
-
Method Details
-
interrupt
-
isInterrupted
public boolean isInterrupted()- Overrides:
isInterruptedin classThread
-
executeWithInterruptDeferred
Defer interrupts for the duration of some task. Once the task is complete, any deferred interrupt will be delivered to the thread, thus the thread interrupt status should be checked upon return. If the current thread is not aJBossThread, the task is simply run as-is.- Parameters:
task- the task to run
-
executeWithInterruptDeferred
Defer interrupts for the duration of some task. Once the task is complete, any deferred interrupt will be delivered to the thread, thus the thread interrupt status should be checked upon return. If the current thread is not aJBossThread, the task is simply run as-is.- Type Parameters:
T- the callable's return type- Parameters:
action- the task to run- Returns:
- the value returned from the callable
- Throws:
Exception- if the action throws an exception
-
executeWithInterruptDeferred
Deprecated.Defer interrupts for the duration of some task. Once the task is complete, any deferred interrupt will be delivered to the thread, thus the thread interrupt status should be checked upon return. If the current thread is not aJBossThread, the task is simply run as-is.- Type Parameters:
T- the action's return type- Parameters:
action- the task to run- Returns:
- the value returned from the callable
-
executeWithInterruptDeferred
@Deprecated public static <T> T executeWithInterruptDeferred(PrivilegedExceptionAction<T> action) throws Exception Deprecated.Defer interrupts for the duration of some task. Once the task is complete, any deferred interrupt will be delivered to the thread, thus the thread interrupt status should be checked upon return. If the current thread is not aJBossThread, the task is simply run as-is.- Type Parameters:
T- the action's return type- Parameters:
action- the task to run- Returns:
- the value returned from the callable
- Throws:
Exception- if the action throws an exception
-
applyInterruptDeferredEx
@Deprecated public static <T, U, R, E extends Exception> R applyInterruptDeferredEx(org.wildfly.common.function.ExceptionBiFunction<T, U, throws ER, E> function, T param1, U param2) Deprecated.- Throws:
E
-
applyInterruptDeferredEx
@Deprecated public static <T, R, E extends Exception> R applyInterruptDeferredEx(org.wildfly.common.function.ExceptionFunction<T, R, throws EE> function, T param) Deprecated.- Throws:
E
-
getInterruptDeferredEx
@Deprecated public static <T, E extends Exception> T getInterruptDeferredEx(org.wildfly.common.function.ExceptionSupplier<T, E> supplier) throws EDeprecated.- Throws:
E
-
acceptInterruptDeferredEx
@Deprecated public static <T, E extends Exception> void acceptInterruptDeferredEx(org.wildfly.common.function.ExceptionObjLongConsumer<T, E> consumer, T param1, long param2) throws EDeprecated.- Throws:
E
-
acceptInterruptDeferredEx
@Deprecated public static <T, E extends Exception> void acceptInterruptDeferredEx(org.wildfly.common.function.ExceptionObjIntConsumer<T, E> consumer, T param1, int param2) throws EDeprecated.- Throws:
E
-
acceptInterruptDeferredEx
@Deprecated public static <T, U, E extends Exception> void acceptInterruptDeferredEx(org.wildfly.common.function.ExceptionBiConsumer<T, U, throws EE> consumer, T param1, U param2) Deprecated.- Throws:
E
-
acceptInterruptDeferredEx
@Deprecated public static <T, E extends Exception> void acceptInterruptDeferredEx(org.wildfly.common.function.ExceptionConsumer<T, E> consumer, T param) throws EDeprecated.- Throws:
E
-
runInterruptDeferredEx
@Deprecated public static <E extends Exception> void runInterruptDeferredEx(org.wildfly.common.function.ExceptionRunnable<E> runnable) throws E Deprecated.- Throws:
E
-
applyInterruptResumedEx
@Deprecated public static <T, U, R, E extends Exception> R applyInterruptResumedEx(org.wildfly.common.function.ExceptionBiFunction<T, U, throws ER, E> function, T param1, U param2) Deprecated.- Throws:
E
-
applyInterruptResumedEx
@Deprecated public static <T, R, E extends Exception> R applyInterruptResumedEx(org.wildfly.common.function.ExceptionFunction<T, R, throws EE> function, T param) Deprecated.- Throws:
E
-
getInterruptResumedEx
@Deprecated public static <T, E extends Exception> T getInterruptResumedEx(org.wildfly.common.function.ExceptionSupplier<T, E> supplier) throws EDeprecated.- Throws:
E
-
acceptInterruptResumedEx
@Deprecated public static <T, E extends Exception> void acceptInterruptResumedEx(org.wildfly.common.function.ExceptionObjLongConsumer<T, E> consumer, T param1, long param2) throws EDeprecated.- Throws:
E
-
acceptInterruptResumedEx
@Deprecated public static <T, E extends Exception> void acceptInterruptResumedEx(org.wildfly.common.function.ExceptionObjIntConsumer<T, E> consumer, T param1, int param2) throws EDeprecated.- Throws:
E
-
acceptInterruptResumedEx
@Deprecated public static <T, U, E extends Exception> void acceptInterruptResumedEx(org.wildfly.common.function.ExceptionBiConsumer<T, U, throws EE> consumer, T param1, U param2) Deprecated.- Throws:
E
-
acceptInterruptResumedEx
@Deprecated public static <T, E extends Exception> void acceptInterruptResumedEx(org.wildfly.common.function.ExceptionConsumer<T, E> consumer, T param) throws EDeprecated.- Throws:
E
-
runInterruptResumedEx
@Deprecated public static <E extends Exception> void runInterruptResumedEx(org.wildfly.common.function.ExceptionRunnable<E> runnable) throws E Deprecated.- Throws:
E
-
run
-
onExit
Register a runnable task to be executed when the current thread exits.- Parameters:
hook- the task to run- Returns:
trueif the task was registered;falseif the task isnullor if the current thread is not an instance ofJBossThread- Throws:
SecurityException- if a security manager is installed and the caller's security context lacks themodifyThreadRuntimePermission
-
currentThread
Get the currentJBossThread, ornullif the current thread is not aJBossThread.- Returns:
- the current thread, or
null
-
start
public void start()Start the thread.- Overrides:
startin classThread- Throws:
IllegalThreadStateException- if the thread was already started.
-
setUncaughtExceptionHandler
Change the uncaught exception handler for this thread.- Overrides:
setUncaughtExceptionHandlerin classThread- Parameters:
eh- the new handler
-
getAndSetInterruptHandler
Swap the current thread's active interrupt handler. Most callers should restore the old handler in afinallyblock like this:InterruptHandler oldHandler = JBossThread.getAndSetInterruptHandler(newHandler); try { ...execute interrupt-sensitive operation... } finally { JBossThread.getAndSetInterruptHandler(oldHandler); }- Parameters:
newInterruptHandler- the new interrupt handler- Returns:
- the old interrupt handler
-
applyWithInterruptHandler
@Deprecated public static <T, U, R, E extends Exception> R applyWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionBiFunction<T, U, throws ER, E> function, T param1, U param2) Deprecated.- Throws:
E
-
applyWithInterruptHandler
@Deprecated public static <T, R, E extends Exception> R applyWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionFunction<T, R, throws EE> function, T param1) Deprecated.- Throws:
E
-
getWithInterruptHandler
@Deprecated public static <R, E extends Exception> R getWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionSupplier<R, E> function) throws EDeprecated.- Throws:
E
-
acceptWithInterruptHandler
@Deprecated public static <T, E extends Exception> void acceptWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionObjLongConsumer<T, E> function, T param1, long param2) throws EDeprecated.- Throws:
E
-
acceptWithInterruptHandler
@Deprecated public static <T, E extends Exception> void acceptWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionObjIntConsumer<T, E> function, T param1, int param2) throws EDeprecated.- Throws:
E
-
acceptWithInterruptHandler
@Deprecated public static <T, U, E extends Exception> void acceptWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionBiConsumer<T, U, throws EE> function, T param1, U param2) Deprecated.- Throws:
E
-
acceptWithInterruptHandler
@Deprecated public static <T, E extends Exception> void acceptWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionConsumer<T, E> function, T param1) throws EDeprecated.- Throws:
E
-
runWithInterruptHandler
@Deprecated public static <E extends Exception> void runWithInterruptHandler(InterruptHandler interruptHandler, org.wildfly.common.function.ExceptionRunnable<E> function) throws E Deprecated.- Throws:
E
-