mirror of
https://github.com/denoland/deno.git
synced 2024-12-20 14:24:48 -05:00
0fd8f549e2
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
9 lines
281 B
JavaScript
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'.
|
|
}
|