Java Swing Programming Question:

What is the What is the difference between invokeAndWait() and invokeLater()? ?

Tweet Share WhatsApp

Answers:

Answer #1invokeAndWait() method in swing is synchronous. It blocks until Runnable task is complete. InvokeLater() method in swing is asynchronous. It posts an action event to the event queue and returns immediately. It will not wait for the task to complete

Answer #2difference between invokeAndWait() and invokeLater() is invokeAndWait() keeps the code on to event thread and waits till the execution of run method is completed whereas invokeLater() keeps the code on event thread and runs the rest of code in the thread.

Download Java Swing Programming PDF Read All 26 Java Swing Programming Questions
Previous QuestionNext Question
Which method of the Component class is used to set the position and size of a component?Why should any swing call back implementation execute quickly?