酒水不犯茶水
葉的離去,是風的追求還是樹的不挽留?
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
閱讀(365)
評論(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項目(52259)
2.?Unicode編碼表/0000-0FFF(19458)
3.?水果機密碼解碼 "密碼公式" 看了就知道怎么打暴機了(ZT)(17709)
4.?打算做個HackRF(17292)
5.?Raspberry Pi 入手安裝配置 (有圖有真相)(15001)
評論排行榜
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
主站蜘蛛池模板:
四虎国产精品免费久久
|
免费的一级片网站
|
亚洲日韩国产精品乱-久
|
日本a级片免费看
|
十八禁在线观看视频播放免费
|
日本久久久久亚洲中字幕
|
午夜成年女人毛片免费观看
|
精选影视免费在线
|
亚洲乱码在线视频
|
国产偷v国产偷v亚洲高清
|
我要看免费的毛片
|
在线成人精品国产区免费
|
亚洲熟妇av午夜无码不卡
|
亚洲av午夜成人片精品网站
|
天天摸天天碰成人免费视频
|
国产色无码精品视频免费
|
亚洲精品国产首次亮相
|
亚洲专区在线视频
|
亚洲国产成人精品久久久国产成人一区二区三区综
|
免费中文字幕一级毛片
|
国产精品免费福利久久
|
欧洲亚洲国产精华液
|
亚洲美女免费视频
|
亚洲尤码不卡AV麻豆
|
国产色婷婷精品免费视频
|
亚洲毛片免费观看
|
中文字幕av免费专区
|
国产1000部成人免费视频
|
h视频免费高清在线观看
|
亚洲国产成人综合精品
|
亚洲色av性色在线观无码
|
亚洲精品尤物yw在线影院
|
国内外成人免费视频
|
精品成在人线AV无码免费看
|
中文字幕免费在线看
|
老司机免费午夜精品视频
|
2020天堂在线亚洲精品专区
|
久久亚洲国产精品成人AV秋霞
|
亚洲线精品一区二区三区影音先锋
|
久久国产精品一区免费下载
|
七次郎成人免费线路视频
|