Created
April 7, 2020 06:12
-
-
Save srebalaji/a5dd636b13bf309abb74e305866af0e8 to your computer and use it in GitHub Desktop.
Message channel in Worker threads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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