Results 1 to 2 of 2
  1. #1
    simorgh is offline Member
    Join Date
    Jan 2010
    Posts
    25
    Rep Power
    0

    Default simple question: A multithread situation

    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:

    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

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    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

Similar Threads

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •