com.samskivert.swing.util
Class TaskMaster
java.lang.Object
com.samskivert.swing.util.TaskMaster
public class TaskMaster
- extends Object
The task master provides the ability for swing applications to invoke
tasks on another thread and to conveniently receive the results of
those tasks back on the swing event dispatch thread where the swing
application can safely manipulate its user interface in response to the
results of the task.
Each task is run in it's own thread. Tasks are assumed to be
infrequently run and expensive, so the overhead of creating a new
thread to run each task is considered acceptable. If the need arises,
the task master can be extended to support more sophisticated thread
pooling but we'll cross that bridge when we come to it.
|
Method Summary |
static void |
invokeMethodTask(String name,
Object source,
TaskObserver observer)
Invokes the method with the specified name on the supplied source
object as if it were a task. |
static void |
invokeTask(String name,
Task task,
TaskObserver observer)
Instructs the task master to run the supplied task. |
protected static void |
removeTask(String name)
Called by the task runner to remove itself from the task table when
the task has completed or been aborted. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_tasks
protected static Hashtable<String,TaskMaster.TaskRunner> _tasks
TaskMaster
public TaskMaster()
invokeTask
public static void invokeTask(String name,
Task task,
TaskObserver observer)
- Instructs the task master to run the supplied task. The task is
given the supplied name and can be referenced by that name in
subsequent dealings with the task master. The supplied observer (if
non-null) will be notified when the task has completed.
invokeMethodTask
public static void invokeMethodTask(String name,
Object source,
TaskObserver observer)
- Invokes the method with the specified name on the supplied source
object as if it were a task. The observer is notified when the
method has completed and returned its result or if it fails. The
named method must have a signature the same as the
invoke method of the Task interface.
Aborting tasks run in this way is not supported.
removeTask
protected static void removeTask(String name)
- Called by the task runner to remove itself from the task table when
the task has completed or been aborted.
Copyright © 2000-2008 Michael Bayne.
All Rights Reserved.