1 2 3 4 5 6 7 8 9 10
onmessage = function () { var counter = 0; var id = setInterval(function () { ++counter; if (counter == 2) { clearInterval(id); postMessage("done"); } }, 0); };