Search |
||
Improve application performance with SwingWorkerPosted by joconner on January 19, 2007 at 1:51 PM PST
I've put database queries right there in my GUI event handlers. I'm ashamed, very ashamed. I've seen a lot of code from others too, and I'm not alone in this mishandling of lengthy IO bound tasks. People sometimes actually perform web You know what I'm talking about, right? I'm talking about the unresponsive, sluggish user interfaces that cause so many critics to believe that Java is so slow. Some of you (me too) have perhaps unknowingly contributed to their list of evidence. If you've been intimidated by threads or if you've ever wondered how to fix all that messed up GUI event handling code that does way more than it should, you'll be pleased to know that Java SE 6 offers some relief. The Using Imagine you have an application that responds to a button click by downloading an image. You might be tempted to put the image retrieval code right there in the event handler itself. If you're feeling good, maybe you refactor a bit, pulling that code into its own method, etc. However, it's still on the EDT. The result is that your UI can't respond to other events while its trekking out across the web. You'll notice the delay...nothing works on the GUI until the image finally arrives. The figure below shows such a thread. During the time between points
Using
Next week, I'm going to post a complete demo with source and tutorial information about how to use this class. I had a great time using »
Related Topics >>
Open JDK Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|