View page on GitHub

Multi Threaded Javascript

On some browsers applets can cause unexpected multi threaded javascript

Run Multi Threaded

On at least IE 10, when a javascript call to the applet blocks then the browser starts executing other scheduled javascript code. This seems to be a violation of the Javascript single threaded constraint. The test code below demonstrates this problem. You can run this code with the link above. When this code is run on IE 10 the following output is logged

starting first bit of code
running second bit of code
ending first bit of code

In normal Javascript execution the second block of code should never run while the first block is still executing. Based on some testing on a single IE 10 machine, I found that this only happens if the applet sleeps for more than 250 milliseconds. That isn’t a precise number, sometimes it is a bit more sometimes a bit less.