<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>
"use strict";
function timedProcessArray(items, process, callback) {
var todo = items.concat(); //create a clone of the original
setTimeout(function doSmall() {
var start = +new Date();
do {
process(todo.shift());
} while (todo.length > 0 && (+new Date() - start < 50));
if (todo.length > 0) {
setTimeout(doSmall, 25);
} else {
callback(items);
}
}, 25);
} function dothing() {
timedProcessArray([dothings1, dothings2],
function(f) {
f();
},
function() {
console.log('done1');
});
} function dothings1() {
console.log('dothings1')
} function dothings2() {
console.log('dothings2')
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div onclick="dothing()">
hello
</div>
</form>
</body>
</html>

http://www.nczonline.net/blog/2009/08/11/timed-array-processing-in-javascript/

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/arguments/callee

Timed Code的更多相关文章

  1. Java多线程系列--“JUC锁”03之 公平锁(一)

    概要 本章对“公平锁”的获取锁机制进行介绍(本文的公平锁指的是互斥锁的公平锁),内容包括:基本概念ReentrantLock数据结构参考代码获取公平锁(基于JDK1.7.0_40)一. tryAcqu ...

  2. Java多线程系列--“JUC锁”04之 公平锁(二)

    概要 前面一章,我们学习了“公平锁”获取锁的详细流程:这里,我们再来看看“公平锁”释放锁的过程.内容包括:参考代码释放公平锁(基于JDK1.7.0_40) “公平锁”的获取过程请参考“Java多线程系 ...

  3. Java多线程系列--“JUC锁”05之 非公平锁

    概要 前面两章分析了"公平锁的获取和释放机制",这一章开始对“非公平锁”的获取锁/释放锁的过程进行分析.内容包括:参考代码获取非公平锁(基于JDK1.7.0_40)释放非公平锁(基 ...

  4. Java多线程系列--“JUC锁”08之 共享锁和ReentrantReadWriteLock

    概要 Java的JUC(java.util.concurrent)包中的锁包括"独占锁"和"共享锁".在“Java多线程系列--“JUC锁”02之 互斥锁Ree ...

  5. Cygwin Run in the Windows(Simulation of UNIX)

    Preface Environment Cygwin Run in the Windows(Simulation of UNIX) Resource Cygwin Install:http://cyg ...

  6. J.U.C并发框架源码阅读(三)ReentrantLock

    基于版本jdk1.7.0_80 java.util.concurrent.locks.ReentrantLock 代码如下 /* * ORACLE PROPRIETARY/CONFIDENTIAL. ...

  7. J.U.C并发框架源码阅读(十七)ReentrantReadWriteLock

    基于版本jdk1.7.0_80 java.util.concurrent.locks.ReentrantReadWriteLock 代码如下 /* * ORACLE PROPRIETARY/CONFI ...

  8. ReentrantReadWriteLock(读写锁)全部源码注释

    package java.util.concurrent.locks; import java.util.concurrent.TimeUnit; import java.util.Collectio ...

  9. hue报错StructuredException: timed out (code THRIFTSOCKET): None的处理

    通过hue的web界面进行hive的sql查询,无法显示结果并报错timeout 报错如下:[28/Jul/2017 11:23:29 +0800] decorators ERROR error ru ...

随机推荐

  1. Maven+Spring Batch+Apache Commons VF学习

    Apache Commons VFS资料:例子:http://www.zihou.me/html/2011/04/12/3377.html详细例子:http://p7engqingyang.iteye ...

  2. poj 2299 Ultra-QuickSort(求逆序对)

    Ultra-QuickSort Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 52778   Accepted: 19348 ...

  3. C++视频课程小结(1)

    C++远征之起航篇 章节介绍: 每章小结: 第一章:C++诞生于贝尔实验室,C++包含C语言. 第二章:介绍了IDE环境(虽然没怎么懂),还推荐使用visual stdio 2010 旗舰版(姑且下了 ...

  4. 1001.A+B Format (20)(思路,bug发现及其修改,提交记录)

    https://github.com/031502316a/object-oriented/tree/master/1001 ---恢复内容开始--- 1.解题思路 一开始见到题目时,感觉难的就是输出 ...

  5. 求C#开发大神指点职业规划或者开发路数(以后怎么走),谢谢

    背景:作为一名Asp.net Web类的开发人员,工作时间有点长,5年不到,属于是天赋不太强,但是比较努力型的人,开发过程中那事情基本上都会,各种前后端框架也会使用.目前在研究分布式缓存应用 Memc ...

  6. tableviewcell 系统工具删除:左滑删除,选中多个删除

    在编辑tableview的时候,我们有时候会需要编辑对一些cell进行删除(增加),在这个时候,我们最好用系统的方法来进行增删的操作 // // text1Controller.m // text / ...

  7. 《dive into python3》 笔记摘录

    1.list can hold  arbitrary  objects and can expand dynamically as new items are added. A list is an  ...

  8. vss使用详解

    下面已VSS6.0为主: 一:安装VSS6.0 安装过程中可能会提示 退出,禁止(abort)  重试(retry)  忽略,跳过(Ignore)  ,我们选 Ignore  跳过此项, 路径自己选择 ...

  9. ExtJs内的datefield控件选择日期过后的事件监听select

    [摘要]: 选择时间过后我们为什么需要监听事件?一般有这样一种情况,那就是用于比较两个时间大小或者需要判断在哪个时间点上需要做什么样的操作.基于这样的种种情况,我们很有必要琢磨一下datefield控 ...

  10. Error loading: \Java\jdk1.6.0_35\jre\bin\server\jvm.dll

    先看看错误:complie: [exec] Error loading: D:\Program Files\Java\jdk1.6.0_35\jre\bin\server\jvm.dll [exec] ...