Application freezes while updating UI... e.g. disabling a button

Hi All,

I am working on a simple desktop java application. On a certain event, one of the threads in the app needs to disable a button.

Under certain circumstances, about one times out of ten, the thread hangs. Following is the stack trace of the thread -

"DiscretesMonitor" prio=6 tid=0x033b6658 nid=0xb18 runnable [0x04aaf000..0x04aafc64]

at sun.awt.windows.WGlobalCursorManager.findHeavyweightUnderCursor(Native Method)

at sun.awt.GlobalCursorManager._updateCursor(Unknown Source)

at sun.awt.GlobalCursorManager.updateCursorImmediately(Unknown Source)

at sun.awt.windows.WComponentPeer.updateCursorImmediately(Unknown Source)

at java.awt.Component.updateCursorImmediately(Unknown Source)

at java.awt.Component.disable(Unknown Source)

- locked <0x22fe3318> (a java.awt.Component$AWTTreeLock)

at javax.swing.JComponent.disable(Unknown Source)

at java.awt.Component.enable(Unknown Source)

at java.awt.Component.setEnabled(Unknown Source)

at javax.swing.JComponent.setEnabled(Unknown Source)

Apparently the thread goes in a wait state while executing sun.awt.windows.WGlobalCursorManaer.findHeavyweightUnderCursor (Native Method).

If any one has any idea what can cause the thread to lock while executing JButton.setEnabled(), please let me know. If you know of any other means to further diagnose the issue, please do share.

Another question is-

In Java, are multiple threads allowed to update UI..

Could the issue mentioned above be because of the fact that I am updating the UI from thread other than EventQueue.

Thanks

[1654 byte] By [alice007a] at [2007-10-3 6:43:34]
# 1

> In Java, are multiple threads allowed to update UI..

No.

> Could the issue mentioned above be because of the fact that I am updating the UI from thread other than EventQueue.

Maybe.

Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html]How to Use Threads[/url] for more information and an explanation on how to place your code in the event thread.

camickra at 2007-7-15 1:32:59 > top of Java-index,Desktop,Core GUI APIs...