Class WorkerTask


  • public abstract class WorkerTask
    extends java.lang.Object
    A task that partially executes on a non-ui thread and partially on the ui thread.

    It is common to have tasks that have a non-ui portion followed by a ui portion. For example, a database query must take place on a non-ui thread because is it a blocking call. The code that takes the results of that query must execute on the UI thread if it is to update UI components.

    This task will be called in the following way. First, the method runOnWorkerThread() will be called from a non-UI thread. At some point later (usually almost immediately), the method runOnUIThread() will be called from the UI thread.

    Version:
    $Revision: 1.3 $
    • Constructor Summary

      Constructors 
      Constructor Description
      WorkerTask()
      Create an instance of the worker task.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract void runOnUIThread()
      Perform ui related work in this method
      abstract void runOnWorkerThread()
      Perform non-ui related work in this method
      • Methods inherited from class java.lang.Object

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

      • WorkerTask

        public WorkerTask()
        Create an instance of the worker task.
    • Method Detail

      • runOnWorkerThread

        public abstract void runOnWorkerThread()
                                        throws java.lang.Exception
        Perform non-ui related work in this method
        Throws:
        java.lang.Exception - Whenever needed
      • runOnUIThread

        public abstract void runOnUIThread()
                                    throws java.lang.Exception
        Perform ui related work in this method
        Throws:
        java.lang.Exception - Whenever needed