Re: Can I control listener update frequency?

David Rosenstrauch <[email protected]> Thu, 7 Feb 2008 10:15:01 -0500
Newsgroups gmane.comp.windows.devel.java.advanced
Message-ID <[email protected]>
Carfield Yim wrote:
> Currently we have an GUI application which will get message from
> server and update collections in memory, then the collections will
> trigger event listener and update SWT table. However, if there are too
> many messages coming back from server, the GUI will be un-responsive
> because too many update. Can I make the listener at most update SWT
> table 10 times per second???

Take the messages and dump them into a (threadsafe) queue.  Then have
another thread that periodically removes everything from the queue,
prunes duplicate/obsolete messages, and then updates the collections
(i.e., triggering the listener event).  This will slow your event
processing down so that the GUI will be responsive.

The new java.util.concurrent classes should make it easy for you to
write this in a threadsafe manner.

BTW, I know you said you want to have this happen every 1/10th of a
second, but frankly I still think that's too fast for a GUI.  People's
brains can't even process information changes that fast.  I'd say once
every second (or half-second - max) should be sufficient.

HTH,

DR

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com