12 lines
263 B
TypeScript
12 lines
263 B
TypeScript
import { parentPort, threadId } from "worker_threads";
|
|
|
|
if (parentPort === null) {
|
|
throw new Error("parentPort is null");
|
|
}
|
|
|
|
parentPort.on("message", message => {
|
|
if (message.workerId !== threadId) {
|
|
throw new Error("threadId is not consistent");
|
|
}
|
|
});
|