Class ShutdownableThread
java.lang.Object
java.lang.Thread
io.confluent.kafka.schemaregistry.utils.ShutdownableThread
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
KafkaStoreReaderThread
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionShutdownableThread(String name) ShutdownableThread(String name, boolean isInterruptible) ShutdownableThread(String name, boolean isInterruptible, String logPrefix) -
Method Summary
Modifier and TypeMethodDescriptionvoidAfter calling initiateShutdown(), use this API to wait until the shutdown is complete.abstract voiddoWork()This method is repeatedly invoked until the thread shuts down or this method throws an exceptionbooleanbooleanbooleanbooleanbooleanvoidCauses the current thread to wait until the shutdown is initiated, or the specified waiting time elapses.voidrun()voidshutdown()Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Field Details
-
logPrefix
-
-
Constructor Details
-
ShutdownableThread
-
ShutdownableThread
-
ShutdownableThread
-
-
Method Details
-
shutdown
- Throws:
InterruptedException
-
isShutdownInitiated
public boolean isShutdownInitiated() -
isShutdownComplete
public boolean isShutdownComplete() -
isThreadFailed
public boolean isThreadFailed()- Returns:
- true if there has been an unexpected error and the thread shut down
-
initiateShutdown
public boolean initiateShutdown() -
awaitShutdown
After calling initiateShutdown(), use this API to wait until the shutdown is complete.- Throws:
InterruptedException
-
pause
Causes the current thread to wait until the shutdown is initiated, or the specified waiting time elapses.- Parameters:
timeout- wait time in units.unit- TimeUnit value for the wait time.- Throws:
InterruptedException
-
doWork
public abstract void doWork()This method is repeatedly invoked until the thread shuts down or this method throws an exception -
run
public void run() -
isRunning
public boolean isRunning()
-