阿西河

所有教程

公众号
🌙
阿西河前端的公众号

我的收藏

    最近访问  (文章)

      教程列表

      抓包专区
      测试专区

      Node.js worker_threads MessageChannel 类

      Node.js worker_threads MessageChannel 类

      新增于: v10.5.0

      Instances of the worker.MessageChannel class represent an asynchronous, two-way communications channel. The MessageChannel has no methods of its own. new MessageChannel() yields an object with port1 and port2 properties, which refer to linked MessagePort instances.

      const { MessageChannel } = require('worker_threads');
      
      const { port1, port2 } = new MessageChannel();
      port1.on('message', (message) => console.log('received', message));
      port2.postMessage({ foo: 'bar' });
      // prints: received { foo: 'bar' } from the `port1.on('message')` listener
      

      更多内容请参考:Node.js worker_threads 工作线程,或者通过 点击对应菜单 进行查看;


      目录
      本文目录
      目录