[jboss-user] [JBoss Seam] - Re: SwingWorker and the Event Dispatcher Thread

SmokingAPipe do-not-reply at jboss.com
Sun Mar 4 14:31:46 EST 2007


Well, SwingWorker itself is a lot different from just handling things asynchronously.  It's a thread class that you sub-class, and you have a few methods:

doInBackground: When the SwingWorker is executed, this is the part that starts running.  Obviously it happens in a thread so the GUI keeps on redrawing and responding to events.  This is the essence of good Swing app building.  doInBackground can publish notifications to...

process(): This receives information of various types from doInBackground and CAN safely update the GUI.  process() runs on the EDT and must return quickly.

and finally...

done(): this runs on the EDT after everything else is done.

This is the only right way to handle things in Swing (either using SwingWorker or some other similar thread-based model).  And many processes on the web are similar.  The web request must return promptly, just like things on the EDT must return promptly.  Long-running work should not be done either during the web request or on the EDT, for similar reasons.  In both cases we would like a publish() method to update the user of the status of long-running work.  And in both cases we want a done() method to let the user know that the long-running task is done.

MDBs are not as light-weight or as natural of a fit as SwingWorker, but they're one of the few ways I can see to do things asynchronously within the Seam world.  I could be totally wrong on that of course, being a newbie to it.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024927#4024927

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024927



More information about the jboss-user mailing list