| Author |
What happens to events when an actionlistener is hogging the event dispatch thread
|
Alistair Parler
Greenhorn
Joined: May 24, 2009
Posts: 11
|
|
Hi,
This is probably a really dumb question, but I'd appreciate any help: I'm just curious.
If I have an actionlistener which is executing its actionPerformed inside the AWT event dispatch thread (i.e. we haven't done the correct thing of either doing the work in a new thread so it doesn't hog the event dispatch thread, or doing the work in an invokeLater if it manipulates any Swing components), what happens to the peer events from the OS when this is running: do they get queued ready for dispatch when the actionPerformed returns?
Thanks,
Alistair
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
Welcome to JavaRanch
As far as I can remember, events (and anything else) queue until the thread is available, but I am not sure. You will have to try it out with two actionListeners; that might verify it. Does the threading policy link help?
|
 |
Alistair Parler
Greenhorn
Joined: May 24, 2009
Posts: 11
|
|
Thanks Campbell!
I just wrote this program and tested it by clicking Btn1 and then Btn2 lots of times. After the sleep had completed, the remaining events were pumped, then the program terminated. So they are indeed queued.
Thanks,
Alistair
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
Well done You have verified queuing for a simple example, so presumably queuing is normal behaviour.
|
 |
 |
|
|
subject: What happens to events when an actionlistener is hogging the event dispatch thread
|
|
|