"Turn" advanced Front end 3.6 JavaScript multithreaded--concurrent.thread.js, webwork

Source: Internet
Author: User

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 ~ ~

WebWork

WebWork 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.