protected abstract static class UnilateralSortMerger.ThreadBase<E> extends Thread implements Thread.UncaughtExceptionHandler
The threads are designed to terminate themselves when the task they are set up to do is completed. Further more,
they terminate immediately when the shutdown()
method is called.
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
protected UnilateralSortMerger.CircularQueues<E> |
queues
The queue of empty buffer that can be used for reading;
|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Modifier | Constructor and Description |
---|---|
protected |
ThreadBase(ExceptionHandler<IOException> exceptionHandler,
String name,
UnilateralSortMerger.CircularQueues<E> queues,
AbstractInvokable parentTask)
Creates a new thread.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
go()
Equivalent to the run() method.
|
protected void |
internalHandleException(IOException ioex)
Internally handles an exception and makes sure that this method returns without a problem.
|
boolean |
isRunning()
Checks whether this thread is still alive.
|
void |
run()
Implements exception handling and delegates to go().
|
void |
shutdown()
Forces an immediate shutdown of the thread.
|
void |
uncaughtException(Thread t,
Throwable e) |
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
protected final UnilateralSortMerger.CircularQueues<E> queues
protected ThreadBase(ExceptionHandler<IOException> exceptionHandler, String name, UnilateralSortMerger.CircularQueues<E> queues, AbstractInvokable parentTask)
exceptionHandler
- The exception handler to call for all exceptions.name
- The name of the thread.queues
- The queues used to pass buffers between the threads.parentTask
- The task that started this thread. If non-null, it is used to register this thread.public void run()
protected abstract void go() throws IOException
IOException
- Exceptions that prohibit correct completion of the work may be thrown by the thread.public boolean isRunning()
public void shutdown()
protected final void internalHandleException(IOException ioex)
ioex
- The exception to handle.public void uncaughtException(Thread t, Throwable e)
uncaughtException
in interface Thread.UncaughtExceptionHandler
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.