mirror of
https://github.com/denoland/deno.git
synced 2024-12-20 14:24:48 -05:00
10 lines
281 B
JavaScript
10 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'.
|
||
|
}
|