kiwi.util
Class Task

java.lang.Object
  |
  +--kiwi.util.Task

public abstract class Task
extends Object
implements Runnable

This class represents an asynchronous task whose progress can be tracked by a ProgressObserver.

Version:
1.0 (10/98)
Author:
Mark Lindner, PING Software Group
See Also:
ProgressObserver, ProgressDialog, Runnable

Constructor Summary
Task()
          Construct a new Task.
 
Method Summary
 void addProgressObserver(ProgressObserver observer)
          Add a progress observer to this task's list of observers.
protected  void notifyObservers(int percent)
          Notify all observers about the percentage of the task completed.
 void removeProgressObserver(ProgressObserver observer)
          Remove a progress observer from this task's list of observers.
abstract  void run()
          Run the task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Task

public Task()
Construct a new Task.
Method Detail

run

public abstract void run()
Run the task. This method is the body of the thread for this task.
Specified by:
run in interface Runnable

addProgressObserver

public final void addProgressObserver(ProgressObserver observer)
Add a progress observer to this task's list of observers. Observers are notified by the task of progress made.
Parameters:
observer - The observer to add.

removeProgressObserver

public final void removeProgressObserver(ProgressObserver observer)
Remove a progress observer from this task's list of observers.
Parameters:
observer - The observer to remove.

notifyObservers

protected final void notifyObservers(int percent)
Notify all observers about the percentage of the task completed.
Parameters:
percent - The percentage of the task completed, an integer value between 0 and 100 inclusive. Values outside of this range are silently clipped.