mirror of
https://github.com/denoland/deno.git
synced 2024-12-30 11:16:38 -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 {};
|