Skip to content

Instantly share code, notes, and snippets.

@srebalaji
Created April 7, 2020 06:12
Show Gist options
  • Save srebalaji/a5dd636b13bf309abb74e305866af0e8 to your computer and use it in GitHub Desktop.
Save srebalaji/a5dd636b13bf309abb74e305866af0e8 to your computer and use it in GitHub Desktop.
Message channel in Worker threads
const { MessageChannel } = require('worker_threads')
const {port1, port2} = new MessageChannel()
port1.once('message', (msg) => {
console.log(msg)
})
port2.postMessage({msg: "hello world"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment