 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Niva Guest
|
Posted: Tue Dec 05, 2006 12:01 am Post subject: application hangs (deadlock?) - swing |
|
|
I use the [AWT-Windows] thread to process a native requests from our
code using JNI, on a swing application (a simple gui I wrote) - which
works great except it sometimes hangs - on specific places. I suspend
the relevant threads to examine the stack and find out the following
(for example)
________________________________________
Thread [AWT-Windows] (Suspended)
Object.wait(long) line: not available [native method]
EventQueue$1AWTInvocationLock(Object).wait() line: not available
EventQueue.invokeAndWait(Runnable) line: not available
SwingUtilities.invokeAndWait(Runnable) line: not available
Communicator.execute(byte[]) line: 109 <== our
class
WToolkit.eventLoop() line: not available [native method]
WToolkit.run() line: not available
Thread.run() line: not available
________________________________________
a short look on EventQueue thread shows:
________________________________________
Thread [AWT-EventQueue-0] (Suspended)
WComponentPeer._requestFocus(Component, boolean, boolean, long) line:
not
available [native method] [local variables
unavailable]
WFramePeer(WComponentPeer).requestFocus(Component, boolean, boolean,
long)
line: not available
JTabbedPane(Component).requestFocusHelper(boolean, boolean) line: not
available
JTabbedPane(Component).requestFocusInWindow() line: not available
JTabbedPane(JComponent).requestFocusInWindow() line: not available
DefaultKeyboardFocusManager.dispatchEvent(AWTEvent) line: not
available
NivasApplication(Component).dispatchEventImpl(AWTEvent) line: not
available
NivasApplication(Container).dispatchEventImpl(AWTEvent) line: not
available
NivasApplication(Window).dispatchEventImpl(AWTEvent) line: not
available
NivasApplication(Component).dispatchEvent(AWTEvent) line: not
available
EventQueue.dispatchEvent(AWTEvent) line: not available
SequencedEvent.dispatch() line: not available
EventQueue.dispatchEvent(AWTEvent) line: not available
EventDispatchThread.pumpOneEventForHierarchy(int, Component) line: not
available
EventDispatchThread.pumpEventsForHierarchy(int, Conditional,
Component) line: not available
EventDispatchThread.pumpEvents(int, Conditional) line: not available
EventDispatchThread.pumpEvents(Conditional) line: not available
EventDispatchThread.run() line: not available
________________________________________
other places it gets stuck on is "getComponents", "enableNativeIME",
"getLightHeavyWeightCursor" etc.
Im sure that to the eye of an expert it all makes sense. we call lock
on eventQueue which wait for something to happen, but where am I going
wrong? why doenst the event happen? are we holding something it needs? |
|
| Back to top |
|
 |
Thomas Hawtin Guest
|
Posted: Tue Dec 05, 2006 1:05 am Post subject: Re: application hangs (deadlock?) - swing |
|
|
Niva wrote:
| Quote: | I use the [AWT-Windows] thread to process a native requests from our
code using JNI, on a swing application (a simple gui I wrote) - which
works great except it sometimes hangs - on specific places. I suspend
the relevant threads to examine the stack and find out the following
(for example)
Thread [AWT-Windows] (Suspended)
Object.wait(long) line: not available [native method]
EventQueue$1AWTInvocationLock(Object).wait() line: not available
EventQueue.invokeAndWait(Runnable) line: not available
Thread [AWT-EventQueue-0] (Suspended)
WComponentPeer._requestFocus(Component, boolean, boolean, long) line:
not
available [native method] [local variables
unavailable]
|
I'm not familiar with the native code of Sun's implementation of AWT for
Windows. However: It looks as if WComponentPeer._requestFocus is waiting
for the AWT-Windows thread to process an event. Much the equivalent of
calling invokeAndWait, only for the other thread. So with both threads
attempting invokeAndWait on the other, we have a deadlock (although it
wouldn't appear in stack traces as such, they are equivalent).
So what I suggest you do is use EventQueue.invokeLater, and from that
task call the equivalent of invokeLater on the AWT-Windows thread.
Tom Hawtin |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|