HTML5 worker Multithreading

Source: Internet
Author: User

Test Browser: FF 3.6 test server: APACHE 2.2 let's assume that if multithreading can be used on the WEB page, does it mean that the WEB page gradually replaces the client? After HTML5 specifications are completed, the multi-thread WEB is a Xiami? Literally, we should see that its implementation is the WORKER mode. What is the WORKER mode? Those who have written multithreading should be clearer than me. The general concept is that the creation of a thread is determined by a WORKER and a thread pool is maintained. Next, let's take a look at the features of HTML5 multithreading: 1. DOM nodes cannot be operated in the thread (messages can only be sent to the worker creator's callback function if you want to operate. the essence of Multithreading is actually a real system thread. functions such as setTimeout (), clearTimeout (), setInterval (), and clearInterval () can be used. the general process of performing I/O operations (ajax) worker is like this: Create a worker object and bind it to the onmessage method that receives messages from the background and the onerror method onerror. Use postMessage to transmit data. The parameters of this method are strict JSON objects. When the background processing is complete, use the postMessage method to send data back to the foreground, that is, the onmessage method. Next let's look at the example: in this example, A number is passed on the page to add 3 to the background, and then the caller is displayed on the page: <! DOCTYPE html>

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.