Hi Reto,
thanks for the feedback. See comments below:
Reto Grob wrote:
> In order to solve that, you can simply make sure that only one thread at
> a time can access the object. This can be done using the "synchronized"
> statement in Java.
>
> It does not mean that you need to do that in the event handling thread.
Unfortunately, this is not the case with many gui libraries. The trouble
with this reasoning is that not all of the updates to the gui data
structures are performed from my application code, the gui library itself
will sometimes perform updates.
For example, when a user types text into a TextBox, the gui library will
update the data structures representing the text of the TextBox without
traversing my application code. There is no opportunity to synchronize
prior to this update.
If the gui library were to expose an appropriate object on which we both
agreed to synchronize before updating then your strategy would be feasible,
however the nttdocomo documentation does not mention such an object.
The traditional solution is to insist that all interaction with the gui
is done from the event handling thread and to provide means for other
threads to move work to the event handling thread. For example, this is
the strategy used by the swing libraries, see:
http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html
Unfortunately, without an invokeLater style method or more guidance from
documentation, it's hard to see how one could write a safe multi-threaded
gui application with the docomo libraries.
Regards, Trent.
--
Trent Hill
Software Engineer
Gravana Pty Ltd (trading as Bullant Software)
Received on Mon Jun 16 04:12:49 2003