public abstract class StoppableThread extends java.lang.Thread implements ExceptionListenerUser
Modifier and Type | Field and Description |
---|---|
protected EnvironmentImpl |
envImpl |
Modifier | Constructor and Description |
---|---|
protected |
StoppableThread(EnvironmentImpl envImpl,
java.lang.String threadName) |
protected |
StoppableThread(EnvironmentImpl envImpl,
java.lang.Thread.UncaughtExceptionHandler handler,
java.lang.Runnable runnable,
java.lang.String threadName) |
protected |
StoppableThread(EnvironmentImpl envImpl,
java.lang.Thread.UncaughtExceptionHandler handler,
java.lang.String threadName) |
protected |
StoppableThread(java.lang.String threadName) |
Modifier and Type | Method and Description |
---|---|
protected void |
cleanup()
Must be invoked upon, or soon after, exit from the thread to perform
any cleanup, and ensure that any allocated resources are freed.
|
protected abstract java.util.logging.Logger |
getLogger() |
java.lang.Exception |
getSavedShutdownException()
Returns the exception if any that provoked the shutdown
|
long |
getTotalCpuTime()
Returns the total cpu time associated with the thread, after the thread
has been shutdown.
|
long |
getTotalUserTime()
Returns the total cpu time associated with the thread, after the thread
has been shutdown.
|
protected int |
initiateSoftShutdown()
Threads that use shutdownThread() must define this method.
|
boolean |
isShutdown() |
void |
saveShutdownException(java.lang.Exception shutdownException) |
void |
setExceptionListener(ExceptionListener exceptionListener)
Set every time a new exception listener is registered.
|
protected boolean |
shutdownDone()
Shutdown methods should only be executed once.
|
void |
shutdownThread(java.util.logging.Logger logger)
This method is invoked from another thread of control to shutdown this
thread.
|
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, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
protected final EnvironmentImpl envImpl
protected StoppableThread(java.lang.String threadName)
protected StoppableThread(EnvironmentImpl envImpl, java.lang.String threadName)
protected StoppableThread(EnvironmentImpl envImpl, java.lang.Thread.UncaughtExceptionHandler handler, java.lang.String threadName)
protected StoppableThread(EnvironmentImpl envImpl, java.lang.Thread.UncaughtExceptionHandler handler, java.lang.Runnable runnable, java.lang.String threadName)
protected abstract java.util.logging.Logger getLogger()
public java.lang.Exception getSavedShutdownException()
public void saveShutdownException(java.lang.Exception shutdownException)
public boolean isShutdown()
public void setExceptionListener(ExceptionListener exceptionListener)
setExceptionListener
in interface ExceptionListenerUser
protected boolean shutdownDone()
protected void cleanup()
public void shutdownThread(java.util.logging.Logger logger)
initiateSoftShutdown()
. If the thread does not exit on its
own in waitMs
the thread is interrupted.
waitMs
is determined by the technique used for the soft
shutdown. For example, if the thread polls on a periodic basis, it could
span one or more polling periods.
All Stoppable threads are expected to catch an interrupt, clean up and
then exit.logger
- the logger on which to log messagesprotected int initiateSoftShutdown()
public long getTotalCpuTime()
public long getTotalUserTime()
Copyright (c) 2004-2012 Oracle. All rights reserved.