2

When 2 events are simultaneously triggered in JavaScript, the javascript engine use a single queue (first procedure in, first out), or the engine internally create independent threads? and if is the second option(there could be concurrency problems due to this).

Thanks beforehand, for your time :)

asked Sep 12, 2012 at 1:39
1
  • I thought all event driven engines were single thread. The other option is thread blocking right? I only know php / js, so that could be wrong. Commented Sep 12, 2012 at 1:45

1 Answer 1

5

JavaScript is single-threaded. Two events cannot occur completely simultaneously, so they are handled in the order in which they arrive.

answered Sep 12, 2012 at 1:40
Sign up to request clarification or add additional context in comments.

2 Comments

I think so, but I think that's the only exception.
Yes WebWorkers get their own thread but when they are done the results are fed back to the queue which forces the output to be executed on the main thread once the stack has cleared. They are good for really heavy lifting like processing image data.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.