Sponsors: Michael Fertik - Best JAVA Web hosting Company & 30% off


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-13-2010, 08:14 PM
Member
 
Join Date: Jan 2010
Posts: 24
Rep Power: 0
simorgh is on a distinguished road
Default simple question: A multithread situation
Quote:
My 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)
WPF Threads: Build More Responsive Apps With The Dispatcher


I cannt get the point. May someone give me an example of this:

Quote:
I was helping write a pharmacy application that had to be able to show every drug in a complex formulary.

What does it mean?
Quote:
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
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 01-13-2010, 08:25 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 8,431
Rep Power: 11
Fubarable is on a distinguished road
Default
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
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multithread Chat server/client gwaldarick Advanced Java 3 09-19-2009 12:22 AM
What should the program look like for this situation megironi New To Java 4 02-22-2009 11:16 AM
Help design a program - multithread? rushenas New To Java 4 01-23-2009 06:41 AM
StringBuffer situation orchid New To Java 6 08-12-2008 01:39 PM
Probably a really simple question... ibanez270dx New To Java 0 11-16-2007 01:27 AM


Java Forums is supported by the best jsp hosting.

All times are GMT +2. The time now is 05:39 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org