Java Swing Programming Question:

Download Job Interview Questions and Answers PDF

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

Java Swing Programming Interview Question
Java Swing Programming Interview Question

Answers:

Answer #1
invokeAndWait() 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 #2
difference 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 Interview Questions And Answers PDF

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?