Methods Summary |
---|
public void | complete()This method is called inside the Swing event queue. An implementation
of this class does not need to implement this method unless it
wants processing to occur specifically in the event queue.
|
public static void | invokeWorker(com.imaginary.swing.WorkerThread wt)Places a worker thread object onto the worker queue for
execution in the worker thread. When the time is right, the
run() method in the specified WorkerThread
object will be run inside the worker thread. Upon completion,
the complete() method will then be executed inside
the event queue.
synchronized( queue ) {
queue.push(wt);
if( worker == null ) {
worker = new Thread() {
public void run() {
runThread();
}
};
worker.setDaemon(true);
worker.setPriority(Thread.NORM_PRIORITY);
worker.setName("Worker Queue");
worker.start();
}
}
|
public abstract void | run()Implementors must implement this method to specify the processing
that should occur in the worker thread.
|
private static void | runThread()
while( true ) {
final WorkerThread wt;
synchronized( queue ) {
if( queue.isEmpty() ) {
worker = null;
return;
}
wt = (WorkerThread)queue.pop();
}
try {
Runnable r;
wt.run();
r = new Runnable() {
public void run() {
wt.complete();
}
};
// place a call to the complete() method in the event queue
SwingUtilities.invokeLater(r);
}
catch( Exception e ) {
e.printStackTrace();
}
}
|