mirror of
https://github.com/denoland/deno.git
synced 2024-11-15 16:43:44 -05:00
17 lines
434 B
JavaScript
17 lines
434 B
JavaScript
|
for (let i = 0; i < 4; i++) {
|
||
|
const worker = new Worker(
|
||
|
new URL("./workers/message_before_close.js", import.meta.url).href,
|
||
|
{ type: "module", name: String(i) },
|
||
|
);
|
||
|
|
||
|
worker.addEventListener("message", (message) => {
|
||
|
// Only print responses after all reception logs.
|
||
|
setTimeout(() => {
|
||
|
console.log("response from worker %d received", message.data);
|
||
|
}, 500);
|
||
|
});
|
||
|
worker.postMessage(i);
|
||
|
}
|
||
|
|
||
|
export {};
|