Examples folder created
[poolifier.git] / examples / yourWorker.js
diff --git a/examples/yourWorker.js b/examples/yourWorker.js
new file mode 100644 (file)
index 0000000..5036d57
--- /dev/null
@@ -0,0 +1,19 @@
+'use strict'
+const { ThreadWorker } = require('../lib/workers')
+
+class MyWorker extends ThreadWorker {
+  constructor () {
+    super((data) => {
+      for (let i = 0; i <= 10000; i++) {
+        const o = {
+          a: i
+        }
+        JSON.stringify(o)
+      }
+      // console.log('This is the main thread ' + isMainThread)
+      return { ok: 1 }
+    })
+  }
+}
+
+module.exports = new MyWorker()