Results 1 to 2 of 2
- 01-13-2010, 08:14 PM #1Member
- Join Date
- Jan 2010
- Rep Power
simple question: A multithread situationMy first real experience with responsiveness goes way back to Visual C++® and MFC and the first grid I ever wrote. I was helping write a pharmacy application that had to be able to show every drug in a complex formulary. The problem was that there were 30,000 drugs, so we decided to give the appearance of responsiveness by filling the first screenful of drugs in the UI thread (in about 50 milliseconds), then using a background thread to finish filling the non-visible drugs (in about 10 seconds)
I cannt get the point. May someone give me an example of this:
I was helping write a pharmacy application that had to be able to show every drug in a complex formulary.
What does it mean?
The problem was that there were 30,000 drugs, so we decided to give the appearance of responsiveness by filling the first screenful of drugs in the UI thread
I don't know about other GUI libraries, but the Swing library uses one thread, the Event Dispatch Thread (EDT) to do all GUI painting and user interaction (capturing button presses, mouse clicks, etc...). If an app tries to query a database with thousands of entries on the EDT, the GUI will come to a grinding halt and will become completely unresponsive, and for that reason, most Swing code would do database queries, and indeed all business logic off the EDT and in a background thread.
But having said this, you don't want the user twiddling their thumbs looking at a non-frozen GUI, but still one that doesn't display any information until the database operations are complete. So one solution that the person above suggested was to do a quick initial query on the EDT, display the results of this, and then do a large background task off of the EDT in a background thread.
If coding in Swing, another way to solve this is to use a SwingWorker object and publish interim results to the EDT via the publish and process methods.
If I'm confusing you even more, sorry, but please read this: Concurrency in Swing
- By gwaldarick in forum Advanced JavaReplies: 3Last Post: 09-19-2009, 12:22 AM
- By megironi in forum New To JavaReplies: 4Last Post: 02-22-2009, 11:16 AM
- By rushenas in forum New To JavaReplies: 4Last Post: 01-23-2009, 06:41 AM
- By orchid in forum New To JavaReplies: 6Last Post: 08-12-2008, 01:39 PM
- By ibanez270dx in forum New To JavaReplies: 0Last Post: 11-16-2007, 01:27 AM