audreyt / node-webworker-threads

Lightweight Web Worker API implementation with native threads
https://npmjs.org/package/webworker-threads
Other
2.3k stars 149 forks source link

Small question #156

Closed p3x-robot closed 7 years ago

p3x-robot commented 7 years ago

Ciao! How are you? Do you know why it is silent? No ouput, if I add setInterval, it silent, if I remove setInterval, it works.

var Worker = require('webworker-threads').Worker;
// var w = new Worker('worker.js'); // Standard API

// You may also pass in a function:
var worker = new Worker(function(){
    postMessage("I'm working before postMessage('ali').");

    setInterval(function() {
        postMessage("I'm working before postMessage('ali').");
    }, 1000)

    this.onmessage = function(event) {
        postMessage('Hi ' + event.data);
//        self.close();
    };
});
worker.onmessage = function(event) {
    console.log("Worker said : " + event.data);
};
worker.postMessage('ali');
audreyt commented 7 years ago

At the moment we do not have support for setInterval. Pull requests welcome. :-)