HTML5(Web Workers)





计数:



/**
 * Created by renzhenming on 2018/3/12.
 */
var i=0;
//t=setTimeout(timedCount,1000)
//1000毫秒后执行timedCount函数,而timedCount函数里面又有t=setTimeout(timedCount,1000)
//,然后就一直执行了
function timedCount()
{
    i=i+1;
    postMessage(i);
    setTimeout("timedCount()",500);
}

timedCount();

你可能感兴趣的:(HTML5(Web Workers))