Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

invokeLater() and invokeAndWait()

843804Feb 17 2005 — edited Feb 17 2005
I'm somewhat confused about when to use these.

from http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html - it says "you must take extreme care that Swing components and models are created, modified, and queried only from the event-dispatching thread"

I also understand that these two methods are basically the same though invokeAndWait only returns once the run() has completed while invokeLater will return immediately.

So, when should I use these? and which one should I use?


If I'm creating the GUI initially, use the invokeAndWait()
If I'm updating/quering the GUI components, use invokeLater()

is this the correct way of thinking?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 17 2005
Added on Feb 17 2005
3 comments
624 views