

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Why doesn't JavaScript support multithreading?
JavaScript used to be single-threaded. It runs using what is called an event loop.
The Event Loop has one simple job — to monitor the Call Stack and the Callback Queue. If the Call Stack is empty, it will take the first event from the queue and will push it to the Call Stack, which effectively runs it.
JS in browsers doesn't support multithreading in the event loop as it is not needed for 99.999% of the websites. The event loop handles everything seamlessly.
For the remaining apps, devs can use web workers. Web Workers are a simple means for web content to run scripts in background threads. The worker thread can perform tasks without interfering with the user interface. In addition, they can perform I/O using XMLHttpRequest (although the responseXML and channel attributes are always null). Once created, a worker can send messages to the JavaScript code that created it by posting messages to an event handler specified by that code (and vice versa). This article provides a detailed introduction to using web workers.
- Related Questions & Answers
- Why doesn't MySQL support millisecond / microsecond precision?
- Why doesn't C++ support functions returning arrays
- Why doesn't JavaScript have a goto statement?
- Python3 - Why loop doesn't work?
- Why Training Doesn’t Help Your Organization!
- Why C/C++ variables doesn’t start with numbers
- Why does C++ require a cast for malloc() but C doesn't?
- Why final variable doesn't require initialization in main method in java?
- Why JavaScript 'var null' throw an error but 'var undefined' doesn't?
- Why subclass doesn't inherit the private instance variables of superclass in Java?
- How to deal with Internet Explorer and addEventListener problem "Object doesn't support this property or method" in JavaScript?
- MySQL system variable table_type doesn't work?
- jQuery .val change doesn't change input value?
- Getting Error message “Object doesn't support property or method 'attachEvent'” in IE11 to call SAP system
- CSS content: attr() on HTML5 progress doesn't work