You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
241 B
13 lines
241 B
// worker的优化计算
|
|
worker.onMessage(function(res){
|
|
console.log('这是worker内部线程打印的')
|
|
console.log(res)
|
|
let sum = add(res.x,res.y);
|
|
worker.postMessage({
|
|
sum : sum
|
|
})
|
|
});
|
|
|
|
function add(x, y){
|
|
return x + y;
|
|
}
|