[java-gnome-hackers] threads
Brought to you by:
afcowie
From: Mark H. <mh...@ca...> - 2003-02-21 12:53:43
|
Hi, I think you've already found that gtk, like swing, requires that almost all graphics operations must be performed in a single thread. Your timer looks interesting, but I think this would only be useful for a limited number of cases. Perhaps it would be more useful to create methods similar to SwingUtilities.invokeAndWait(Runnable) and SwingUtilities.invokeLater(Runnable), which execute the run method of the given class in the graphics thread. These methods are used for everything which updates the display from additional threads. I was going to suggest at this point that Timer could be based on those, but now realise that it would probably have severe performance issues. So it's probably best if we have both a timer and invokeLater (or similar) methods. For your API Proposal, I would suggest that you make it more like the Thread class, in that the user can either override it (e.g. if they want to change it's functionality), or they can supply a Runnable object to its constructor (when they want to use the default behaviour). -- .''`. Mark Howard : :' : `. `' http://www.tildemh.com `- mh...@de... | mh...@ti... | mh...@ca... |