Original link: http://www.cnblogs.com/woodk/articles/5199536.html
JavaScript multi-threading, before the HTML5 webwork not appear many people are using concurrentthread.js analog multithreading.
Often, we also use setinterval and settimeout to simulate multithreading.
Introduction to the concept of multithreading
The browser event triggers the thread, and the ajax,settimeout,setinterval is placed in the back of the program pool.
Concurrent.Thread.js
Concurrent.Thread.js, a Japanese-developed package for JavaScript to be multithreaded, allows us to use the front-end to simulate multi-threading for time-consuming tasks.
: http://download.csdn.net/download/include_define/796952
Tutorial Document: http://www.cnblogs.com/0banana0/archive/2011/06/01/2067402.html
Let's try it here:
1 <! DOCTYPE html> 2
Can be found that the div can be printed in the normal response to the time, very cow broke a library ~ ~
WebWorkWebWork is a JavaScript running in the background, independent of other scripts, without affecting the performance of the page. You can continue to do anything you want to do: Click, select Content, and so on, while the Web worker runs in the background.
Note:the DOM cannot be manipulated asynchronously! WebWork cannot be used locally
HTML5 WebWork method of Use : http://www.cnblogs.com/yxlblogs/p/3896786.html
Webwork.html
<! DOCTYPE html>
Task.js
OnMessage = function (event) { var num = event.data; var result = 0; for (var i = 0; i < num; i++) { result + = i; Console.log (result); } Creates a feed back message to the thread postMessage (result);}
If you feel that reading this article is helpful to you, please click " recommend " button, your "recommendation" will be my biggest writing motivation!
"Turn" advanced Front end 3.6 JavaScript multithreaded--concurrent.thread.js, webwork