I was looking for any solution for my problem:
I want a program, using JavaScript, that executes a mathematical operation for X amount of time. Is it possible? Is there a way to interrupt the current execution thread using JavaScript or some other libraries?
What I want is, have a mathematical operation executing itself into a loop and, for example, in a minute finishes even if the loop isn't complete.
(The only way I think something similar is asking during the loop if the amount of time is minor than 1 minute, but I don't want to do busy waiting)
The mathematical operation is:
var serie = 0;
for ( var j=1; j <= 5; j++ ){
for ( var k=1; k <= 100000; k++ ){
serie = serie + ( Math.log(k)/Math.LN2 ) + (3*k/2*j) + Math.sqrt(k) + Math.pow(k, j-1);
}
}