Skip to main content

Thread Safety

No replies
Joined: 2004-08-17

Hello Mark,

I have also question concerning threading. I noticed that getInstance() methods in ActionManager and TargetManager are not synchronized – do you assume that these classes will be accessed only from the event dispatching thread?
It may be not always the case, for the following reasons:

Most of components that in our GUIs listen for state changes of external devices – so they will run in different threads (e.g threads receiving updates from a JMS broker). It is quite possible that these components want e.g. to add or remove a Targetable from TargetManager. Such action doesn’t change GUI so normally it wouldn’t have to be executed in the Swing thread. Without synchronization one needs to use ‘invokeLater’. I think it would be more convenient to synchronize these methods (and maybe also some others).

What do you think?