JavaScript Multi-Threading – How to Implement Multi-Threading in JavaScript

javascriptwebweb-applicationsweb-development

Well these days JavaScript is main player in all web development technologies , on client side for making user interface better, client side logic, on some web servers as server side logic also

Add to that the fact of people (at least some of them ) started moving in web game development from flash to javascript and HTML5

Isn't it time for it to support multi threading ! are there browsers that allow JavaScript to be multi threaded or is it there in any standards , HTML5 or future versions ?!

Best Answer

Multi threading will not be done in EcmaScript but can be exposed in host environments.

The classic examples are WebWorkers which allows you to spin up a background worker to do work in and abusing <iframe>'s as a way to spawn new processes.

It should be noted that multi threading in JavaScript is not needed (there are exceptions, mainly graphics related programs). You don't need multiple threads, you already have an event loop for your GUI and your graphics rendering (canvas) is hardware accelerated (meaning the GPU renders your graphics in parallel for you).

Although projects like webcl are pretty exciting.

Related Topic