Java Threads Question:

Download Job Interview Questions and Answers PDF

What is the SwingUtilities.invokeLater(Runnable) method for?

Java Threads Interview Question
Java Threads Interview Question

Answer:

The static utility method invokeLater(Runnable) is intended to execute a new runnable thread from a Swing application without disturbing the normal sequence of event dispatching from the Graphical User Interface (GUI). The method places the runnable object in the queue of Abstract Windowing Toolkit (AWT) events that are due to be processed and returns immediately. The runnable object's run() method is only called when it reaches the front of the queue.

The deferred effect of the invokeLater(Runnable) method ensures that any necessary updates to the user interface can occur immediately, and the runnable work will begin as soon as those high priority events are dealt with. The invoke later method might be used to start work in response to a button click that also requires a significant change to the user interface, perhaps to restrict other activities, while the runnable thread executes.

Download Java Threads Interview Questions And Answers PDF

Previous QuestionNext Question
Is there a separate stack for each thread in Java?What is the volatile modifier for?