Class PausableThread

java.lang.Object
java.lang.Thread
org.oscim.utils.PausableThread
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
TileLoader

public abstract class PausableThread extends Thread
An abstract base class for threads which support pausing and resuming.
  • Constructor Details

    • PausableThread

      public PausableThread()
  • Method Details

    • awaitPausing

      public final void awaitPausing()
      Causes the current thread to wait until this thread is pausing.
    • finish

      public void finish()
    • isPausing

      public final boolean isPausing()
      Returns:
      true if this thread is currently pausing, false otherwise.
    • pause

      public final void pause()
      The thread should stop its work temporarily.
    • proceed

      public final void proceed()
      The paused thread should continue with its work.
    • isCanceled

      public final boolean isCanceled()
    • run

      public final void run()
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • afterPause

      protected void afterPause()
      Called once when this thread continues to work after a pause. The default implementation is empty.
    • afterRun

      protected void afterRun()
      Called once at the end of the run() method. The default implementation is empty.
    • doWork

      protected abstract void doWork() throws InterruptedException
      Called when this thread is not paused and should do its work.
      Throws:
      InterruptedException - if the thread has been interrupted.
    • getThreadName

      protected abstract String getThreadName()
      Returns:
      the name of this thread.
    • getThreadPriority

      protected int getThreadPriority()
      Returns:
      the priority of this thread. The default value is Thread.NORM_PRIORITY.
    • hasWork

      protected abstract boolean hasWork()
      Returns:
      true if this thread has some work to do, false otherwise.