简体   繁体   English

事件是在Javascript中同时执行还是连续执行?

[英]Event execute simultaneously or continuously in Javascript?

I have action event click on a button in Javascript. 我有动作事件,请单击Javascript中的按钮。 If I click the button 2 times, the function handler of the action perform simultaneously or sequence? 如果我单击按钮两次,该动作的功能处理程序是同时执行还是按顺序执行? (the time between 2 click is faster than the function handler execution time). (两次单击之间的时间比函数处理程序的执行时间快)。

Your functions never run in parallel. 您的函数永远不会并行运行。 When an event occurs, the user thread is awoken to execute the registered handler and only when your function finishes may the other function be called. 当事件发生时,用户线程将被唤醒以执行已注册的处理程序,并且只有在您的函数完成后,才能调用另一个函数。

If you don't use webworkers, you never have two of your functions running at the same time in a page. 如果不使用Webworker,则页面中永远不会同时运行两个功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM