酒水不犯茶水
葉的離去,是風(fēng)的追求還是樹的不挽留?
BlogJava
|
首頁
|
發(fā)新隨筆
|
發(fā)新文章
|
聯(lián)系
|
聚合
|
管理
隨筆:325 文章:0 評(píng)論:612 引用:0
在javascript中用command模式模擬多線程 (ZT)
轉(zhuǎn)自:
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
;
//
控制每次運(yùn)行多少個(gè)動(dòng)作
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>
點(diǎn)擊這里查看效果
發(fā)表于 2006-11-23 11:02
009
閱讀(365)
評(píng)論(0)
編輯
收藏
所屬分類:
網(wǎng)頁編程
新用戶注冊(cè)
刷新評(píng)論列表
只有注冊(cè)用戶
登錄
后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關(guān)文章:
一段有趣的腳本
實(shí)例解析蠕蟲病毒的原理(ZT)
JavaScript加密解密7種方法
Flash純腳本生成餅圖(ZT)
清空代碼防止查看源代碼(ZT)
VBS解決終端窗口中特殊快捷鍵問題
Technical explanation of The MySpace Worm
翻動(dòng)100萬級(jí)的數(shù)據(jù)(自定義的MSSQL分頁查詢過程)
Use CDO.Message (cdosys.dll) to send an SMTP Mail with importance (as a VBS Script)
破解所謂的“網(wǎng)頁源代碼加密”
<
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
公告
常用鏈接
我的隨筆
我的評(píng)論
我的參與
最新評(píng)論
留言簿
(113)
給我留言
查看公開留言
查看私人留言
隨筆分類
2D & 3D(14)
(rss)
ajax(3)
(rss)
OTHERS(82)
(rss)
UNIX(27)
(rss)
兄弟(2)
(rss)
系統(tǒng)編程(85)
(rss)
經(jīng)驗(yàn)技巧(51)
(rss)
網(wǎng)絡(luò)資源(8)
(rss)
網(wǎng)頁編程(20)
(rss)
黑客技術(shù)(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)
文章分類
系統(tǒng)編程
(rss)
網(wǎng)絡(luò)資源
(rss)
網(wǎng)頁編程
(rss)
黑客技術(shù)
(rss)
相冊(cè)
080512汶川大地震
20130405
mypic
taobao
ubuntu
W810C
手工
畫畫兒
草莓音樂節(jié)
Link
動(dòng)力老男孩
(rss)
愛上DIY
搜索
最新評(píng)論
1.?re: OsmocomBB項(xiàng)目
@zhou-xuelin
哇~~~多謝多謝!!!
--009
2.?re: OsmocomBB項(xiàng)目
評(píng)論內(nèi)容較長(zhǎng),點(diǎn)擊標(biāo)題查看
--zhou-xuelin
3.?re: OsmocomBB項(xiàng)目
我的顯示未發(fā)現(xiàn)libncurse 軟件包是什么原因呢
--HYH
4.?re: 樓上 惡鄰 小孩 奔跑 咚咚咚
樓下一群跳廣場(chǎng)舞的怎么辦?還天天循環(huán)播放那幾首低俗歌
--斗魚
5.?re: 小米手環(huán)分析[未登錄]
沒看到鬧鐘的內(nèi)容,根據(jù)鬧鐘和震動(dòng)提醒功能,可以做一些應(yīng)用。
--kim
閱讀排行榜
1.?OsmocomBB項(xiàng)目(52271)
2.?Unicode編碼表/0000-0FFF(19458)
3.?水果機(jī)密碼解碼 "密碼公式" 看了就知道怎么打暴機(jī)了(ZT)(17713)
4.?打算做個(gè)HackRF(17293)
5.?Raspberry Pi 入手安裝配置 (有圖有真相)(15002)
評(píng)論排行榜
1.?OsmocomBB項(xiàng)目(118)
2.?打算做個(gè)HackRF(18)
3.?無線鍵盤監(jiān)聽(更新 LCD 1602)(15)
4.?Token Kidnapping Windows 2003 PoC exploit (Win2K3測(cè)試成功)(13)
5.?我是007加密后的軟件密碼破解(13)
Powered by:
博客園
模板提供:
滬江博客
Copyright ©2025 009
2006 ©
009網(wǎng)站
版權(quán)沒有,任意拷貝
如有意見和建議,請(qǐng) E-mail 至
baicker@hotmail.com
建議使用
Firefox & 微軟雅黑字體
進(jìn)行瀏覽,最佳顯示
1400*1050
主站蜘蛛池模板:
久久这里只精品99re免费
|
亚洲kkk4444在线观看
|
一区二区免费电影
|
免费一级做a爰片久久毛片潮喷
|
亚洲中文字幕无码一去台湾
|
亚洲精品乱码久久久久久
|
亚洲精品成人av在线
|
免费人成在线观看视频高潮
|
亚洲中文字幕无码中文字在线
|
国产精品免费视频观看拍拍
|
免费大片黄手机在线观看
|
九九免费观看全部免费视频
|
老司机亚洲精品影视www
|
免费网站观看WWW在线观看
|
亚洲国产精品久久久久
|
无码区日韩特区永久免费系列
|
亚洲成a人片7777
|
妞干网手机免费视频
|
国产亚洲福利精品一区二区
|
亚洲欧洲自拍拍偷精品 美利坚
|
四虎影院免费视频
|
国产亚洲精品欧洲在线观看
|
亚洲综合色自拍一区
|
99精品视频在线观看免费专区
|
亚洲制服丝袜中文字幕
|
国产片免费福利片永久
|
国产在线观看无码免费视频
|
亚洲精品福利网站
|
成在线人永久免费视频播放
|
免费视频一区二区
|
亚洲五月综合缴情婷婷
|
亚洲国产成人精品91久久久
|
久久久久成人片免费观看蜜芽
|
亚洲伊人久久大香线蕉影院
|
亚洲AV网站在线观看
|
久久国产精品2020免费m3u8
|
亚洲免费闲人蜜桃
|
亚洲偷自拍拍综合网
|
亚洲成年人免费网站
|
一出一进一爽一粗一大视频免费的
|
亚洲人成电影福利在线播放
|