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 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.
|
void |
interrupt()
Interrupt this thread.
|
boolean |
isInterrupted() |
void |
run()
Execute the thread's
Runnable . |
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 target#Thread(Runnable)
public JBossThread(Runnable target, String name)
target
- the runnable targetname
- the initial thread name#Thread(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 group#Thread(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 group#Thread(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 group#Thread(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 runT
- the value returned from the callableException
- 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 runT
- the value returned from the callablepublic 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 runT
- the value returned from the callableException
- if the action throws an exceptionpublic void run()
Runnable
. Logs a trace message at the start and end of execution.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 handlerCopyright © 2024 JBoss by Red Hat. All rights reserved.