Package com.jogamp.common.util
Class RunnableTask
- java.lang.Object
-
- com.jogamp.common.util.TaskBase
-
- com.jogamp.common.util.RunnableTask
-
-
Field Summary
Fields Modifier and Type Field Description protected Runnablerunnable-
Fields inherited from class com.jogamp.common.util.TaskBase
attachment, catchExceptions, exceptionOut, execThread, isExecuted, isFlushed, runnableException, sourceStack, syncObject, tCreated, tExecuted, tStarted
-
-
Constructor Summary
Constructors Constructor Description RunnableTask(Runnable runnable, Object syncObject, boolean catchExceptions, PrintStream exceptionOut)Create a RunnableTask object w/ synchronization, ie.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RunnablegetRunnable()Return the user actionstatic RunnableTaskinvokeOnCurrentThread(Runnable runnable)Invokesrunnableon the currentThread.static RunnableTaskinvokeOnNewThread(ThreadGroup tg, String threadName, boolean waitUntilDone, Runnable runnable)Invokesrunnableon a newInterruptSource.Thread, seeThread(ThreadGroup, Runnable, String)for details.voidrun()-
Methods inherited from class com.jogamp.common.util.TaskBase
flush, getAttachment, getDurationInExec, getDurationInQueue, getDurationTotal, getExceptionOutIntro, getExecutionThread, getSyncObject, getThrowable, getTimestampAfterExec, getTimestampBeforeExec, getTimestampCreate, hasWaiter, isExecuted, isFlushed, isInQueue, printSourceTrace, setAttachment, toString
-
-
-
-
Field Detail
-
runnable
protected final Runnable runnable
-
-
Constructor Detail
-
RunnableTask
public RunnableTask(Runnable runnable, Object syncObject, boolean catchExceptions, PrintStream exceptionOut)
Create a RunnableTask object w/ synchronization, ie. suitable forinvokeAndWait(), i.e.invoke(true, runnable).- Parameters:
runnable- The user actionsyncObject- The synchronization object if caller wait untilrunnableexecution is completed, ornullif waiting is not desired.catchExceptions- Influence an occurring exception duringrunnableexecution. Iftrue, the exception is silenced and can be retrieved viaTaskBase.getThrowable(), otherwise the exception is thrown.exceptionOut- If notnull, exceptions are written to thisPrintStream.
-
-
Method Detail
-
invokeOnCurrentThread
public static RunnableTask invokeOnCurrentThread(Runnable runnable)
Invokesrunnableon the currentThread.- Parameters:
runnable- theRunnableto execute on the current thread. The runnable must exit, i.e. not loop forever.- Returns:
- the newly created and invoked
RunnableTask - Since:
- 2.4.0
-
invokeOnNewThread
public static RunnableTask invokeOnNewThread(ThreadGroup tg, String threadName, boolean waitUntilDone, Runnable runnable)
Invokesrunnableon a newInterruptSource.Thread, seeThread(ThreadGroup, Runnable, String)for details.- Parameters:
tg- theThreadGroupfor the new thread, maybenullthreadName- the name for the new thread, maybenullwaitUntilDone- iftrue, waits untilrunnableexecution is completed, otherwise returns immediately.runnable- theRunnableto execute on the new thread. IfwaitUntilDoneistrue, the runnable must exit, i.e. not loop forever.- Returns:
- the newly created and invoked
RunnableTask - Since:
- 2.3.2
-
getRunnable
public final Runnable getRunnable()
Return the user action
-
-