I want to use a timer as a fallback in case I end up in an infinite loop. It seems that set interval is the right way to do this. However, it\'s not working for me.
Fro
zerkms has the correct answer. But I would add that web workers are a way to get some multi-threaded-ish behavior from client side javascript.
var worker = new Worker('my_task.js');
worker.onmessage = function(event) {
console.log("Called back by the worker!\n");
};
The worker runs in a background thread, and you can exchange messages and subscribe to events. It's pretty nifty.