标签:style blog http color java 使用 os io
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <script type="text/javascript"> //创建线程 work对象 var work = new Worker("work.js"); //发送消息 work.postMessage("100"); // 监听消息 work.onmessage = function(event) { alert(event.data); }; </script> </head> <body> </body> </html>
work.js
onmessage = function (event) { //从1加到num var num = event.data; var result = 0; for (var i = 1; i <= num; i++) { result += i; } postMessage(result); }
HTML5学习之WebWork多线程处理(八),布布扣,bubuko.com
标签:style blog http color java 使用 os io
原文地址:http://www.cnblogs.com/yxlblogs/p/3896786.html