var Promise=function(args){ this.callback=[]; var _this=this; setTimeout(function() { _this.done(); }, 0);};Promise.prototype.then=function(res...
分类:
编程语言 时间:
2014-12-04 21:19:41
阅读次数:
154
常见的并发陷阱volatilevolatile只能强调数据的可见性,并不能保证原子操作和线程安全,因此volatile不是万能的。参考指令重排序volatile最常见于下面两种场景。a. 循环检测机制volatilebooleandone=false;while(!done){dosomething...
分类:
编程语言 时间:
2014-12-03 00:19:55
阅读次数:
319
whileCONDITION;dostatement.....done进入循环:条件满足退出循环:条件不满足untilCONDITION;doSTATEMENT.......done进入循环:条件不满足退出循环:条件满足#!/bin/bash#read-p"Inputsomething:"STRINGwhile[$STRING!=‘quit‘];doecho$STRING|tr‘a-z‘‘A-Z‘read-p"Again,Inp..
分类:
其他好文 时间:
2014-12-02 12:01:19
阅读次数:
119
点击打开链接
Bridging signals
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 10951
Accepted: 6000
Description
'Oh no, they've done it again', cries the c...
分类:
其他好文 时间:
2014-12-01 19:17:54
阅读次数:
125
首先看一个简单的没有线程支持的情况下的顺序执行:
from time import sleep, ctime
def loop0():
print('start loop 0 at:', ctime())
sleep(4)
print('loop 0 done at:', ctime())
def loop1():
print('start loop 1 ...
分类:
编程语言 时间:
2014-11-29 21:44:04
阅读次数:
351
Mapping the SwapsSorting an array can be done by swapping certain pairs of adjacent entries in the array. This is the fundamental technique used in th...
分类:
其他好文 时间:
2014-11-28 21:19:28
阅读次数:
245
You can change the partition table on Linux by a group of tools, which is tool comprehansive for a newbee. While I find this work will be easily done ...
分类:
系统相关 时间:
2014-11-27 23:24:51
阅读次数:
177
1 using System; 2 using System.Threading; 3 4 5 namespace WorkerThread02 6 { 7 class ThreadTest 8 { 9 bool done;10 static v...
分类:
编程语言 时间:
2014-11-26 18:09:39
阅读次数:
203
一:大数组转存到文件里,可以考虑逐行写入,并配合多进程来写入/* * 参 数:$file 字符串 文件名 * $key 字符串 数组键名 * $value 字符串 数组键值 * $step 字符串 当前程序步骤,只有三个值:初始化init/执行中doing/完成done * ...
分类:
其他好文 时间:
2014-11-26 16:15:49
阅读次数:
223
1 void reversedir(string srcDir) 2 { 3 struct _finddata_t filefind; 4 string imgName = srcDir + "\\*.*"; 5 int done=0, handle; 6 7 ...