We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <div class="time"></div> <script> setInterval(() => { document.querySelector(".time").innerHTML = new Date() }, 1000); var myWorker = new Worker('/testjs/worker.js'); myWorker.postMessage(39999999); // 监听 worker 完成情况 myWorker.onmessage = function (e) { console.log('result from work:', e.data); } </script> </body> </html>
onmessage = function (e) { let res = 0; for (let i = 0; i < e.data; i++) { res+=i } var workerResult = res; postMessage(workerResult); }
The text was updated successfully, but these errors were encountered:
plh97
No branches or pull requests
先祭上代码
js
前端时刻更新着时间, 分支线程计算数据,互不影响
计算完成,将结果抛出
The text was updated successfully, but these errors were encountered: