Skip to main content

Threading issues for Buttons???

2 replies [Last post]
leo_test
Offline
Joined: 2004-04-27
Points: 0

We are facing the following problem:

User press Button 'Cancel' and then press Button 'Save'. Since we do not like the user to press Cancel and then Save we hide the dialog where the buttons are located. The action to hide the dialog is normally done just after the Cancel press, but not completely after it, just some steps behind.

In a *regular* environment the time between pressing and hiding is about 200ms. But now customer runs the app on a terminal server and this has the impact to slow down the whole processing. Instead of 200ms we have encountered 1900ms and I guess this was due to CPU-shortage.

Now I thinking about a different design with enable/disable buttons within the ActionListeners. Does it improve thread-safeness to have that kind of design? Is there a better one? (e.g. Buttonsgroups, removeing ActionListeners, etc.?) Since I have no idea about the Swing internals, I am curious if two different ActionsListeners might get threading issues or if this is prevented by some design.

There might be still the situation arise of CPU-lack, non-performing app and some additional delay which makes on a normal computer no problem, but on some terminal servers where the time-slices might get short???

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
walterln
Offline
Joined: 2007-04-17
Points: 0

Swing is single threaded, so if you disable a button in one ActionListener than that button should not be able to fire an action event from a following mouse click.

leo_test
Offline
Joined: 2004-04-27
Points: 0

Thx for the insight about single threaded. I'll not implement it via button.enable but with an own variable.

Anyway, very helpful.