public abstract class AbstractControlledThread extends Thread
myRun method which can throw
exceptions. The thread will keep any exception thrown and provides some
additional features.Thread.State, Thread.UncaughtExceptionHandlerMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
AbstractControlledThread()
Creates a new thread.
|
| Modifier and Type | Method and Description |
|---|---|
Throwable |
get_death_exception()
Obtains the throwable that killed the thread.
|
static void |
invoke_all(AbstractControlledThread[] threads)
Calls the
invoke() method on all threads in the array. |
Object |
invoke()
Simulates a thread "invocation" starting the thread, if it has not yet
started and waiting for the thread to die, returning the thread's return
value.
|
abstract Object |
my_run()
Method that will perform the thread's work.
|
Object |
result()
Obtains the execution result (the value returned by
my_run) |
void |
run()
run method: just wraps myRun. |
static void |
start_all(AbstractControlledThread[] threads)
Starts all threads in an array.
|
void |
wait_for_end()
Waits for the thread to die (or for an interrupt).
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldpublic final void run()
run method: just wraps myRun.public abstract Object my_run() throws Exception
Exception - execution failedpublic Throwable get_death_exception()
null if nonepublic Object result()
my_run)null if the thread failed
with an exception or has not finished yetpublic void wait_for_end()
public Object invoke() throws Exception
Exception - the exception thrown by the threadpublic static void start_all(AbstractControlledThread[] threads)
threads - the array of threads to startpublic static void invoke_all(AbstractControlledThread[] threads) throws Exception
invoke() method on all threads in the array. If one
of the methods fail with an exception, the exception is thrown. If
more than one method fails with an exception, one of the exceptions is
thrown and the others suppressed.threads - the thread arrayException - at least one threads failed. This is the exception
thrown by the threadCopyright © 2015. All rights reserved.