Is there any equivalent of Java’s invokeLater() method of SwingUtilities in Javascript?
UPDATE 1
So, will setTimeout() with zero delay do exactly the same as invokeLater()?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to run something asynchronously (later), try
setTimeout()JavaScript is single-threaded. If you want to run some time consuming (CPU-intensive) task outside of the event handler, you can do this using the technique above, however it will still consume event-handling thread (cause your UI to freeze).
It is generally a bad idea to run CPU-intensive tasks inside a browser (web workers might change this) since they share the same thread as event handlers, making them wait.
See also