class ThreadPool.ThreadPoolThread extends Thread
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
private boolean |
doNotifyAll |
private Object |
lock |
private Runnable |
target |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
ThreadPool.ThreadPoolThread(int idx,
String name)
Creates a ThreadPoolThread object, setting its name according to
the given 'idx', daemon type and the priority to the one of the
pool.
|
Modifier and Type | Method and Description |
---|---|
void |
run()
The method that is run by the thread.
|
(package private) void |
setTarget(Runnable target,
Object lock,
boolean notifyAll)
Assigns a target to this thread, with an optional notify lock and a
notify mode.
|
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, yield
private Runnable target
private Object lock
private boolean doNotifyAll
public ThreadPool.ThreadPoolThread(int idx, String name)
idx
- The index of this thread in the poolname
- The name of the threadpublic void run()
An interrupt on this thread has no effect other than forcing a check on the target. Normally the target is checked every time the thread is woken up by notify, no interrupts should be done.
Any exception thrown by the target's 'run()' method is catched and this thread is not affected, except for 'ThreadDeath'. If a 'ThreadDeath' exception is catched a warning message is printed by the 'FacilityManager' and the exception is propagated up. For exceptions which are subclasses of 'Error' or 'RuntimeException' the corresponding error condition is set and this thread is not affected. For any other exceptions a new 'RuntimeException' is created and the error condition is set, this thread is not affected.
void setTarget(Runnable target, Object lock, boolean notifyAll)
target
- The runnable object containing the 'run()' method to
run.lock
- An object on which notify will be called once the
target's run method has finished. A thread to be notified should be
waiting on that object. If null no thread is notified.notifyAll
- If true 'notifyAll()', instead of 'notify()', will
be called on tghe lock.Copyright © 2016 Open Microscopy Environment