Class BackgroundTask

  • Direct Known Subclasses:
    ObjectLoader, PageLoader

    public abstract class BackgroundTask
    extends java.lang.Object
    Allows you to perform long lasting tasks in background. If we ever move to Java 6, we should use the SwingWorker class (included in the JDK) instead of this custom Event Dispatching code.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  BackgroundTask.ThreadWrapper
      Inner class that holds the reference to the thread.
    • Constructor Summary

      Constructors 
      Constructor Description
      BackgroundTask()
      Starts a thread.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void doTask()
      Implement this class; the time-consuming task will go here.
      void finished()
      Called on the event dispatching thread once the construct method has finished its task.
      void interrupt()
      Forces the thread to stop what it's doing.
      void start()
      Starts the thread.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BackgroundTask

        public BackgroundTask()
        Starts a thread. Executes the time-consuming task in the construct method; finally calls the finish().
    • Method Detail

      • doTask

        public abstract void doTask()
        Implement this class; the time-consuming task will go here.
      • start

        public void start()
        Starts the thread.
      • interrupt

        public void interrupt()
        Forces the thread to stop what it's doing.
      • finished

        public void finished()
        Called on the event dispatching thread once the construct method has finished its task.