Re: Can I control listener update frequency?
Peter Booth <[email protected]> Thu, 7 Feb 2008 07:27:43 -0500
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <[email protected]> |
Yes you can, and there are a couple of approaches. Note that SWT's event handling is different than Swings' in that in SWT we depend on the native windowing system to update the GUI. You may find SWT specific patterns/tools on an SWT site. How does your application get messages from your server? Is it a callback mechanism or polling? Assuming it is a callback then you can use a producer/consumer to implement the "chunking" of events you desire. Your callback thread can write an event into a LinkedBlockingQueue or similar. The use from a Timer periodically call queue.poll() until it returns null. CAVEAT: Before doing any coding I would strongly urge that you use YourKit Profiler or OptimizeIt's ThreadDebugger to completely understand what is happening in your application when it is under load. It is very easy to have an incorrect belief about the concurrent behavior of your app and then waste time fixing something that isn't the actual problem. Some useful questions are: "how many is too many events returned from server? Does this number seem reasonable? If I put the application into this too busy state and produce a series of repeated thread dumps what do they show is occurring? Are we doing anything dumb in our event processing?" Hope this helps. Peter On Feb 7, 2008, at 12:35 AM, 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??? > > =================================== > This list is hosted by DevelopMentorĀ® http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com