小编use*_*454的帖子

节点:错误选项:--experimental-worker

我正在尝试在node.js.

const { Worker, isMainThread, parentPort } = require('worker_threads');
if (isMainThread) {
    // This code is executed in the main thread and not in the worker.

    // Create the worker.
    const worker = new Worker(__filename);
    // Listen for messages from the worker and print them.
    worker.on('message', (msg) => { console.log(msg); });
} else {
    // This code is executed in the worker and not in the main thread.

    // Send a message to the main thread.
    parentPort.postMessage('Hello world!'); …
Run Code Online (Sandbox Code Playgroud)

javascript worker-thread node.js

4
推荐指数
1
解决办法
2466
查看次数

标签 统计

javascript ×1

node.js ×1

worker-thread ×1