酒水不犯茶水
葉的離去,是風的追求還是樹的不挽留?
BlogJava
|
首頁
|
發新隨筆
|
發新文章
|
聯系
|
聚合
|
管理
隨筆:325 文章:0 評論:612 引用:0
在javascript中用command模式模擬多線程 (ZT)
轉自:
http://www.tkk7.com/emu/archive/2005/06/08/5775.html
1
<
html
><
head
><
title
>
emu -- 用command模式模擬多線程
</
title
></
head
><
body
>
2
<
SCRIPT
LANGUAGE
="JavaScript"
>
3
<!--
4
if
(Array.prototype.shift
==
null
)
5
Array.prototype.shift
=
function
()
{
6
var
rs
=
this
[
0
];
7
for
(
var
i
=
1
;i
<
this
.length;i
++
)
this
[i
-
1
]
=
this
[i]
8
this
.length
=
this
.length
-
1
9
return
rs;
10
}
11
if
(Array.prototype.push
==
null
)
12
Array.prototype.push
=
function
()
{
13
for
(
var
i
=
0
;i
<
arguments.length;i
++
)
this
[
this
.length]
=
arguments[i];
14
return
this
.length;
15
}
16
17
var
commandList
=
[];
18
var
nAction
=
0
;
//
控制每次運行多少個動作
19
var
functionConstructor
=
function
()
{}
.constructor;
20
function
executeCommands()
{
21
for
(
var
i
=
0
;i
<
nAction;i
++
)
22
if
(commandList.length
>
0
)
{
23
var
command
=
commandList.shift();
24
if
(command.constructor
==
functionConstructor)
25
if
(command.scheduleTime
==
null
||
new
Date()
-
command.scheduleTime
>
0
)
26
command();
27
else
28
commandList.push(command);
29
}
30
}
31
32
function
startNewTask()
{
33
var
resultTemp
=
document.getElementById(
"
sampleResult
"
).cloneNode(
true
);
34
with
(resultTemp)
{
35
id
=
""
;style.display
=
"
block
"
;style.color
=
(Math.floor(Math.random()
*
(
1
<<
23
)).toString(
16
)
+
"
00000
"
).substring(
0
,
6
);
36
}
37
document.body.insertBefore(resultTemp,document.body.lastChild);
38
commandList.push(
function
()
{simThread(resultTemp,
1
);}
);
39
nAction
++
;
40
}
41
42
function
simThread(temp,n)
{
43
if
(temp.stop) n
--
;
44
else
temp.innerHTML
=
temp.innerHTML
-
(
-
n);
45
if
(n
<
1000
)
46
commandList.push(
function
()
{simThread(temp,
++
n)}
);
47
else
{
48
var
command
=
function
()
{document.body.removeChild(temp);;nAction
--
;}
;
49
command.scheduleTime
=
new
Date()
-
(
-
2000
);
50
commandList.push(command);
51
}
52
}
53
54
window.onload
=
function
()
{setInterval(
"
executeCommands()
"
,
1
);}
55
//
-->
56
</
SCRIPT
>
57
<
button
onclick
="startNewTask()"
>
開始新線程
</
button
>
58
59
<
BR
><
BR
>
60
<
div
id
=sampleResult
onmouseover
="this.stop=true"
onmouseout
="this.stop=false"
style
="display:none;cursor:hand"
>
0
</
div
>
61
</
body
>
62
</
html
>
<SCRIPT LANGUAGE="JavaScript"> <!-- if (Array.prototype.shift==null) Array.prototype.shift = function (){ var rs = this[0]; for (var i=1;i<this.length;i++) this[i-1]=this[i] this.length=this.length-1 return rs; } if (Array.prototype.push==null) Array.prototype.push = function (){ for (var i=0;i<arguments.length;i++) this[this.length]=arguments[i]; return this.length; } var commandList = []; var nAction = 0; var functionConstructor = function(){}.constructor; function executeCommands(){ for (var i=0;i<nAction;i++) if (commandList.length>0){ var command = commandList.shift(); if (command.constructor == functionConstructor) if (command.scheduleTime == null || new Date()-command.scheduleTime>0) command(); else commandList.push(command); } } function startNewTask(){ var resultTemp = document.getElementById("sampleResult").cloneNode(true); with (resultTemp){ id="";style.display="block";style.color=(Math.floor(Math.random()* (1<<23)).toString(16)+"00000").substring(0,6); } document.body.insertBefore(resultTemp,document.body.lastChild); commandList.push(function(){simThread(resultTemp,1);}); nAction++; } function simThread(temp,n){ if (temp.stop) n--; else temp.innerHTML = temp.innerHTML - (-n); if (n<1000) commandList.push(function(){simThread(temp,++n)}); else{ var command = function(){document.body.removeChild(temp);;nAction--;}; command.scheduleTime = new Date()-(-2000); commandList.push(command); } } setInterval("executeCommands()",1); //--> </SCRIPT> <button onclick="startNewTask()">開始新線程</button> <BR><BR> <div id=sampleResult onmouseover="this.stop=true" onmouseout="this.stop=false" style="display:none;cursor:hand">0</div>
點擊這里查看效果
發表于 2006-11-23 11:02
009
閱讀(358)
評論(0)
編輯
收藏
所屬分類:
網頁編程
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
一段有趣的腳本
實例解析蠕蟲病毒的原理(ZT)
JavaScript加密解密7種方法
Flash純腳本生成餅圖(ZT)
清空代碼防止查看源代碼(ZT)
VBS解決終端窗口中特殊快捷鍵問題
Technical explanation of The MySpace Worm
翻動100萬級的數據(自定義的MSSQL分頁查詢過程)
Use CDO.Message (cdosys.dll) to send an SMTP Mail with importance (as a VBS Script)
破解所謂的“網頁源代碼加密”
<
2006年11月
>
日
一
二
三
四
五
六
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
公告
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(113)
給我留言
查看公開留言
查看私人留言
隨筆分類
2D & 3D(14)
(rss)
ajax(3)
(rss)
OTHERS(82)
(rss)
UNIX(27)
(rss)
兄弟(2)
(rss)
系統編程(85)
(rss)
經驗技巧(51)
(rss)
網絡資源(8)
(rss)
網頁編程(20)
(rss)
黑客技術(88)
(rss)
隨筆檔案
2021年11月 (1)
2019年7月 (1)
2018年11月 (1)
2016年2月 (1)
2015年9月 (1)
2015年5月 (1)
2015年4月 (2)
2014年10月 (1)
2014年6月 (1)
2014年5月 (1)
2014年3月 (3)
2013年11月 (2)
2013年9月 (1)
2013年6月 (1)
2013年5月 (1)
2013年4月 (1)
2012年12月 (1)
2012年11月 (1)
2012年10月 (1)
2012年8月 (1)
2012年7月 (1)
2012年5月 (2)
2012年4月 (1)
2012年3月 (1)
2011年12月 (3)
2011年11月 (2)
2011年10月 (2)
2011年7月 (2)
2011年2月 (1)
2010年11月 (2)
2010年6月 (2)
2010年5月 (1)
2010年3月 (1)
2010年2月 (1)
2010年1月 (1)
2009年11月 (1)
2009年10月 (2)
2009年9月 (2)
2009年7月 (1)
2009年4月 (1)
2009年2月 (1)
2009年1月 (1)
2008年12月 (1)
2008年10月 (5)
2008年9月 (9)
2008年8月 (6)
2008年7月 (5)
2008年6月 (2)
2008年5月 (8)
2008年4月 (4)
2008年3月 (6)
2008年2月 (5)
2008年1月 (4)
2007年12月 (22)
2007年11月 (15)
2007年10月 (3)
2007年9月 (11)
2007年8月 (40)
2007年7月 (16)
2007年6月 (5)
2007年5月 (16)
2007年4月 (15)
2007年3月 (15)
2007年2月 (4)
2007年1月 (3)
2006年12月 (22)
2006年11月 (14)
文章分類
系統編程
(rss)
網絡資源
(rss)
網頁編程
(rss)
黑客技術
(rss)
相冊
080512汶川大地震
20130405
mypic
taobao
ubuntu
W810C
手工
畫畫兒
草莓音樂節
Link
動力老男孩
(rss)
愛上DIY
搜索
最新評論
1.?re: OsmocomBB項目
@zhou-xuelin
哇~~~多謝多謝?。。?
--009
2.?re: OsmocomBB項目
評論內容較長,點擊標題查看
--zhou-xuelin
3.?re: OsmocomBB項目
我的顯示未發現libncurse 軟件包是什么原因呢
--HYH
4.?re: 樓上 惡鄰 小孩 奔跑 咚咚咚
樓下一群跳廣場舞的怎么辦?還天天循環播放那幾首低俗歌
--斗魚
5.?re: 小米手環分析[未登錄]
沒看到鬧鐘的內容,根據鬧鐘和震動提醒功能,可以做一些應用。
--kim
閱讀排行榜
1.?OsmocomBB項目(52188)
2.?Unicode編碼表/0000-0FFF(19451)
3.?水果機密碼解碼 "密碼公式" 看了就知道怎么打暴機了(ZT)(17534)
4.?打算做個HackRF(17273)
5.?Raspberry Pi 入手安裝配置 (有圖有真相)(14988)
評論排行榜
1.?OsmocomBB項目(118)
2.?打算做個HackRF(18)
3.?無線鍵盤監聽(更新 LCD 1602)(15)
4.?Token Kidnapping Windows 2003 PoC exploit (Win2K3測試成功)(13)
5.?我是007加密后的軟件密碼破解(13)
Powered by:
博客園
模板提供:
滬江博客
Copyright ©2025 009
2006 ©
009網站
版權沒有,任意拷貝
如有意見和建議,請 E-mail 至
baicker@hotmail.com
建議使用
Firefox & 微軟雅黑字體
進行瀏覽,最佳顯示
1400*1050
主站蜘蛛池模板:
久久91亚洲精品中文字幕
|
亚洲高清视频在线
|
成人女人A级毛片免费软件
|
亚洲日韩图片专区第1页
|
国产免费久久精品99re丫y
|
美女羞羞喷液视频免费
|
亚洲AV无码专区国产乱码4SE
|
91在线品视觉盛宴免费
|
一级免费黄色毛片
|
久久狠狠爱亚洲综合影院
|
亚洲精品麻豆av
|
亚洲精品动漫免费二区
|
久久精品成人免费观看97
|
亚洲乱码一区二区三区国产精品
|
国产精品亚洲mnbav网站
|
成人免费午夜无码视频
|
a级毛片在线视频免费观看
|
亚洲精品宾馆在线精品酒店
|
久久国产亚洲观看
|
亚洲AV无码乱码在线观看
|
免费看黄视频网站
|
成全视频在线观看免费
|
免费无码午夜福利片
|
国产成人精品亚洲日本在线
|
亚洲爆乳无码专区
|
亚洲狠狠爱综合影院婷婷
|
最新猫咪www免费人成
|
久久免费精彩视频
|
国产JIZZ中国JIZZ免费看
|
亚洲AV无码成人精品区狼人影院
|
香蕉国产在线观看免费
|
国产成人精品日本亚洲11
|
亚洲国产天堂久久综合网站
|
久久亚洲国产精品
|
亚洲麻豆精品国偷自产在线91
|
成人免费a级毛片
|
1000部羞羞禁止免费观看视频
|
国产精品免费在线播放
|
免费高清A级毛片在线播放
|
亚洲精品美女久久7777777
|
亚洲免费在线视频
|