Modifier and Type | Field and Description |
---|---|
protected Runnable |
runnable |
attachment, catchExceptions, exceptionOut, execThread, isExecuted, isFlushed, runnableException, sourceStack, syncObject, tCreated, tExecuted, tStarted
Constructor and Description |
---|
RunnableTask(Runnable runnable,
Object syncObject,
boolean catchExceptions,
PrintStream exceptionOut)
Create a RunnableTask object w/ synchronization,
ie.
|
Modifier and Type | Method and Description |
---|---|
Runnable |
getRunnable()
Return the user action
|
static RunnableTask |
invokeOnCurrentThread(Runnable runnable)
Invokes
runnable on the current Thread . |
static RunnableTask |
invokeOnNewThread(ThreadGroup tg,
String threadName,
boolean waitUntilDone,
Runnable runnable)
Invokes
runnable on a new InterruptSource.Thread ,
see InterruptSource.Thread#Thread(ThreadGroup, Runnable, String) for details. |
void |
run() |
flush, getAttachment, getDurationInExec, getDurationInQueue, getDurationTotal, getExceptionOutIntro, getExecutionThread, getSyncObject, getThrowable, getTimestampAfterExec, getTimestampBeforeExec, getTimestampCreate, hasWaiter, isExecuted, isFlushed, isInQueue, printSourceTrace, setAttachment, toString
protected final Runnable runnable
public RunnableTask(Runnable runnable, Object syncObject, boolean catchExceptions, PrintStream exceptionOut)
invokeAndWait()
, i.e. invoke(true, runnable)
.runnable
- The user actionsyncObject
- The synchronization object if caller wait until runnable
execution is completed,
or null
if waiting is not desired.catchExceptions
- Influence an occurring exception during runnable
execution.
If true
, the exception is silenced and can be retrieved via TaskBase.getThrowable()
,
otherwise the exception is thrown.exceptionOut
- If not null
, exceptions are written to this PrintStream
.public static RunnableTask invokeOnCurrentThread(Runnable runnable)
runnable
on the current Thread
.runnable
- the Runnable
to execute on the current thread.
The runnable must exit, i.e. not loop forever.RunnableTask
public static RunnableTask invokeOnNewThread(ThreadGroup tg, String threadName, boolean waitUntilDone, Runnable runnable)
runnable
on a new InterruptSource.Thread
,
see InterruptSource.Thread#Thread(ThreadGroup, Runnable, String)
for details.tg
- the ThreadGroup
for the new thread, maybe null
threadName
- the name for the new thread, maybe null
waitUntilDone
- if true
, waits until runnable
execution is completed, otherwise returns immediately.runnable
- the Runnable
to execute on the new thread. If waitUntilDone
is true
,
the runnable must exit, i.e. not loop forever.RunnableTask
public final Runnable getRunnable()