1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-20 14:24:48 -05:00
denoland-deno/tests/testdata/workers/node_worker_auto_exits.mjs
Satya Rohith 0fd8f549e2
fix(ext/node): allow automatic worker_thread termination (#22647)
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2024-03-13 17:22:25 +00:00

9 lines
281 B
JavaScript

import { isMainThread, Worker } from "node:worker_threads";
if (isMainThread) {
// This re-loads the current file inside a Worker instance.
const w = new Worker(import.meta.filename);
} else {
console.log("Inside Worker!");
console.log(isMainThread); // Prints 'false'.
}