Class ShutdownableThread

java.lang.Object
java.lang.Thread
io.confluent.kafka.schemaregistry.utils.ShutdownableThread
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
KafkaStoreReaderThread

public abstract class ShutdownableThread extends Thread
  • Field Details

    • logPrefix

      public final String logPrefix
  • Constructor Details

    • ShutdownableThread

      public ShutdownableThread(String name)
    • ShutdownableThread

      public ShutdownableThread(String name, boolean isInterruptible)
    • ShutdownableThread

      public ShutdownableThread(String name, boolean isInterruptible, String logPrefix)
  • Method Details

    • shutdown

      public void shutdown() throws InterruptedException
      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

      public void awaitShutdown() throws InterruptedException
      After calling initiateShutdown(), use this API to wait until the shutdown is complete.
      Throws:
      InterruptedException
    • pause

      public void pause(long timeout, TimeUnit unit) throws InterruptedException
      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()
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • isRunning

      public boolean isRunning()