Monday, 15 May 2017

nodejs thread usage with variables quest

I'm new here and I created my account today just to ask this

I'm studying nodejs and getting trouble with threads.

var spawn = require("threads").spawn;

for ( i = 0; i < 10; i++ ){
var threads = spawn(function(i){
    console.log(i)
}); 

}

all I want to do is print the thread execution order, but var i is not defined inside spawn function, why?



via J. Doe

No comments:

Post a Comment