Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Event Que  RSS feed

 
Alex Joyce
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

Just a quick question, Is it correct to say that when a thread is passed as an argument in invokeLater(), it is placedd in the event que? then when it reaches the head of the que it is invoked in the event despatch thread?, also, is the event que a strict FIFO? eg, can you get programmitacally fired events to barge to the head of the event que?
Hope that makes sense and thank you in advance for any help.

Alex
 
Scott Delap
author
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex,

When you use invokeLater() it gets posted in the event queue. You are right that when the entry reaches the head it is executed. The normal SwingUtilities always place things at the end. I guess you might be able to programmatically figure out a way to put things on the head. However, the whole idea is that things on the EventQueue should execute as quickly as possible. So position 1 versus 20 shouldn't have that much difference. If they do you need to move the code executed off the EDT if possible. You also might look at the FREE threading chapter from my book on Swing and threading for more Swing EDT related info.

http://www.sourcebeat.com:80/docs/Desktop%20Java%20Live/Rev_2/Desktop%20Java%20Live_SampleChapter.pdf;jsessionid=2747CE93AA451C3EA855C4B8F5DBD1CB

-----------
Scott Delap
ClientJava.com
Desktop Java Live
 
Alex Joyce
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Scott Delap:

Thanks Scott!, what a great piece! Clarified many issues for me regarding swing & threads.. Brilliant!

Thanks for your time..

Alex,

When you use invokeLater() it gets posted in the event queue. You are right that when the entry reaches the head it is executed. The normal SwingUtilities always place things at the end. I guess you might be able to programmatically figure out a way to put things on the head. However, the whole idea is that things on the EventQueue should execute as quickly as possible. So position 1 versus 20 shouldn't have that much difference. If they do you need to move the code executed off the EDT if possible. You also might look at the FREE threading chapter from my book on Swing and threading for more Swing EDT related info.

http://www.sourcebeat.com:80/docs/Desktop%20Java%20Live/Rev_2/Desktop%20Java%20Live_SampleChapter.pdf;jsessionid=2747CE93AA451C3EA855C4B8F5DBD1CB

-----------
Scott Delap
ClientJava.com
Desktop Java Live
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!