diff --git a/workers/process.js b/workers/process.js index c47cc2f..3ddd6d5 100644 --- a/workers/process.js +++ b/workers/process.js @@ -1,13 +1,9 @@ // worker的优化计算 +const math = require('../utils/math') + 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; -} \ No newline at end of file + let sum = math.plus(res.x, res.y) + worker.postMessage({ sum : sum }) +}) \ No newline at end of file