Class ManagedRunnable

java.lang.Object
com.j_spaces.kernel.ManagedRunnable
Direct Known Subclasses:
AbstractSelectorThread, ClientConversationRunner, SelectorManager

public abstract class ManagedRunnable extends Object
A Managed Runnable is a convenient superclass for Runnables that want to support graceful shutdown of threads. When someone wants the thread to be shut down, it calls requestShutdown(). The thread periodically checks if it should shut down by calling shouldShutdown(), and returns from run() if it should.
  • Constructor Details

    • ManagedRunnable

      public ManagedRunnable()
  • Method Details

    • requestShutdown

      public void requestShutdown()
      Request shutdown, this method will be block depends the waitWhileFinish() method implementation.
    • shouldShutdown

      public boolean shouldShutdown()
    • waitWhileFinish

      protected abstract void waitWhileFinish()
      This method will be invoked by requestShutdown(). Request method will be block while waitWhileFinish() will not be finished.