??xml version="1.0" encoding="utf-8" standalone="yes"?>最新四虎影在线在永久观看www,日韩av影片,亚洲成av人片在线观看香蕉http://www.aygfsteel.com/mixer-a/zh-cnTue, 17 Jun 2025 02:08:53 GMTTue, 17 Jun 2025 02:08:53 GMT60D开发悟出的点点滴滴http://www.aygfsteel.com/mixer-a/archive/2012/08/05/384786.htmlmixer-amixer-aSat, 04 Aug 2012 17:27:00 GMThttp://www.aygfsteel.com/mixer-a/archive/2012/08/05/384786.htmlhttp://www.aygfsteel.com/mixer-a/comments/384786.htmlhttp://www.aygfsteel.com/mixer-a/archive/2012/08/05/384786.html#Feedback2http://www.aygfsteel.com/mixer-a/comments/commentRss/384786.htmlhttp://www.aygfsteel.com/mixer-a/services/trackbacks/384786.html作ؓ开发h员,D赚外快是很^常的事!D又可以ؓ我们带来什么呢Q?/strong>

 

个hȝ有四点:

一、Money是万恶之源,生活所|我要赚钱啊!Q?/p>

二、觉得自己技术还不够好,需要通过不断的开发来巩固知识?/p>

三、接目做,其实是个_版项目开发的程Q从业务需求、系l分析与设计、编码、测试,需要的是一个team的相互沟通、合作。在team中实现自我h|创造h|获得个h_升华Q这个赞啊!^_^Q)?/p>

四、业务多了,认识的h也会多v来,圈子自然而然׃滚大Q各行各业的人都有打交道Q这个行业,也是相当重要的?/p>

 

OKQ讲了那么多Q理所当然Q兼职开发是不是必要的?我们又应该如何去做正的做出选择Q作Z个未出社会的菜鸟Q从自己的兼职经历出发,谈谈自己的想法!

2011q暑假得C个机会去了某间公司当PHP开发的实习生,当时应聘的是ASP.NET开发,因公司要求,LPHP了,IT行业的第一份工作,q得q算愉快Q!当时BOSSҎq是挺好的,教了我很多东西,不仅仅是在技术方面,在ؓ人处事方面也有收莗?/p>

实习l束后,下定军_搞好自己的专业方?NET开发,因ؓ觉得自己什么都会点Q但是却没能把一U技术学得熟l点。一个偶然的ZQBOSS介绍了一份兼职给我,大致跟那位客h通过后,主要是ؓ已经上线的网站修攚w面和增减功能Q应该算是技术支持,技术支持?好吧Q基本上要全能型Q前端知识,divQcssQjs要会点,php的joomla开发也要会。这和我自q计划冲突了,左思右惻I抉|不住金钱的诱惑,C了这条忐忑不安的路?/p>

?011q?2月䆾开始,正式合作Q支付方式是每月基本dQ固定工资?/p>

刚开始,主要是做面的修改,前端基础q算可以Q吃着老本Q感觉也杄Q客户也很好沟通,是每天耗的旉比以前多了,逐渐地把_֊都放到工作上了?/p>

寒假q后Q回校了Q发现工作量来大Q量大是指小问题来多Q自己没接触q的功能点也来多Q由于我的客h负责l筹q营q方面,对code不是很熟悉,于是我只能自己找资料Q去QQ,论坛求助Q无形间自己p的时间就来多Q往往一个很单的问题,却要l了一个很大的圈才能解冻I工作效率低了Q自然Q务就积多Q客户也来不满意。关键一点,影响自己学习Q此Ӟ已经有打不做的念头Q可是付出汗水后Q出_的那一刻,我又淡定了,咛_QMoney作怪啊Q我ph深地陷入q个d@环中。。。?/p>

后来因ؓ惛_始准备自q毕设Q加上课E设计要开发电子商务网站,最后,军_不干了,2012q?月䆾底,The EndingQ?nbsp;

 

一轮流水̎后,I竟问题出在哪里呢?

1.支付方式以每月基本Q务,固定工资的方式作为兼职开发的合作形式不妥。客L立场是以最的资金来榨取更多的利润Q当你快速完成了每个d后,接着新的dl箋来,没有喘息的时间。所以,遵@多劳多得的原则,以每个模块,d形式处理更佳Q但需要开发h员能够估好d旉Q把握进度?/p>

2.历时5个月Q周期太ѝQ何一份工作开始时L热情高涨Q但是随着旉的推U,渐渐的变得越来越懒散Q不负责任,只求完成Q不求质量。但更可悲的是,企鹅开始隐w,防止客户打扰。额Q这U服务态度是不行的Q切忌效ѝ?/p>

3.旉不够Q无法兼֭习。上课时?~5个小Ӟ睡眠旉包括午休10个小Ӟ吃饭旉2个小Ӟ体育q动旉1个小Ӟ额!剩下的时间挤吧!

4.沟通能力是非常重要。因Z能和客户面对面沟通,隑օ有些需求会说不清,此时Q请不要敯Q一定要先把完整的需求弄出来Q他惌的功能,惌的效果,在自q能力范围量满他。当自己遇到某些手的问题时Q不要怕,量说出来,虽然他不是很懂codeQ但是他l的Q意见可能帮助到你?/p>

5.单干很篏Q拥有team是很q福的事情。往往一个h开发的时候,遇到问题停滞不前QnҎ伙伴提点下,事半功倍。等我以后出d作了Q希望能遇到好team?/p>

6.做重复的工作Q浪Ҏ_也无法从中学到更多的知识?/p>

 

最后,来个大杂烩!

作ؓ一名学生,D开发可以m固技术,增加开发经验,加强沟通能力。但是要分析利弊Q大学四q可以说是学习的黄金旉Q在q四q里面,打好基础是非帔R要的?/p>

如果你有好的团队Q方可大战拳脚,自己扛不住还有伙伴的帮忙?/p>

如果业务太多了,接项目就需要有针对性,寚w些周期比较短的,目隑ֺ能在自己可控范围内,又能提高自己技术的优先选择?/p>

如果因ؓ学习旉与做目冲突了,q时候就要考虑做项目是否对自己提高技术有帮助了?Q?/p>

E序员们Q不要d怨公司给的工资太,而耗费自己大量旉dU活Q眼光放长远点,不要dMoney看,与其获取一丁点的钱Q倒不如花更多的时间去增D己,学无止境啊!只有慢慢U篏C定的E度后,技术可以过得了养I加薪没问题,以后大把的钞接着来!

 

SOQ自׃开始找工作了,之前学的知识太散了,现在要专一炏V?/strong>

明天要去q州U帆电脑U技公司W试面试Q公司用VB.NET开发,自己没接触过Q加上对q公怸是很了解Q有点犹豫了Q哎Q找工作是烦!Q?/strong>



mixer-a 2012-08-05 01:27 发表评论
]]>
你想不到的压~方法:javascript文g压羃成PNG囑փ存储http://www.aygfsteel.com/mixer-a/archive/2012/08/05/384785.htmlmixer-amixer-aSat, 04 Aug 2012 17:26:00 GMThttp://www.aygfsteel.com/mixer-a/archive/2012/08/05/384785.htmlhttp://www.aygfsteel.com/mixer-a/comments/384785.htmlhttp://www.aygfsteel.com/mixer-a/archive/2012/08/05/384785.html#Feedback4http://www.aygfsteel.com/mixer-a/comments/commentRss/384785.htmlhttp://www.aygfsteel.com/mixer-a/services/trackbacks/384785.html你有没有惌Qؓ了压~js文gQ把js文g转化成PNG囑փQ然后用 canvas 控g中的 getImageData() 函数图像再重新Ljs文g。我昨天在这里发表的JS文g快速加?/a>的文章中提到了这一ҎQ有|友对这个做法很感兴,于是今天详细解读一下?br />
q样可以做到很高的压~比Q到底有多高Q下面会提到。这U方法用C canvas 控gQ这也意味着只有支持 canvas 控g的浏览器下才有效?br />

现在你可以看刎ͼ上面的图像类g个噪声图像,但它实际上是一个由124K?prototype 框架代码转化成的30K?位PNG囑փQ压~比q不错吧Q?br />
其实Q要代码{化ؓ囑փ的格式存储,可以转化成GIF和PNG格式。PNG格式的图像有24位和8位,?4位的RGB囑փQ每个像素可以存?字节的数据,如果是用8位的RGB囑փQ每个像素可以存?字节的数据?br />
在PHOTOSHOP中做试发现Q一?00x100的纯色杂?位图像可以压~到5KQ而同LU色杂点囑փQ如果是100x100?4位图像只能压~到20K。如果是同样图案?位GIF囑փQ压~效果比PNG要差一些。所以,我们选择?位的PNG囑փ作ؓ压羃和解压羃的存储格式?br />
现在Q我们就需要开始压~图像了Q下面是用PHP写的压羃文g地址?br />
http://www.cleanthem.com/code/20120620/js-to-png.txt

它读取JS文gq创Z个PNG囑փQ图像中的每个像素中是一?-255之间的|而这个值对应的是JS字符的ascII的倹{?br />
当然Q除了压~,q要有解压羃Q也是图像读取ؓJS文g的过E。这个函数是用JS写的Q可以从下面的位|下载这个文件?br />http://www.cleanthem.com/code/20120620/pngdata.txt

最后给出在U测试地址Q在q个|页上,您可以在列表中选择一个PNG囑փ文gQ点?load file 按钮可以在网上看到q个囑փQ在囑փ的下面是p个图像所d来的代码文g?/p>

http://www.nihilogic.dk/labs/canvascompress/

 

注:转蝲h明出处,觉得有用推荐一下吧~



mixer-a 2012-08-05 01:26 发表评论
]]>
也谈 GET ?POST 的区?/title><link>http://www.aygfsteel.com/mixer-a/archive/2012/07/29/384256.html</link><dc:creator>mixer-a</dc:creator><author>mixer-a</author><pubDate>Sun, 29 Jul 2012 02:48:00 GMT</pubDate><guid>http://www.aygfsteel.com/mixer-a/archive/2012/07/29/384256.html</guid><wfw:comment>http://www.aygfsteel.com/mixer-a/comments/384256.html</wfw:comment><comments>http://www.aygfsteel.com/mixer-a/archive/2012/07/29/384256.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.aygfsteel.com/mixer-a/comments/commentRss/384256.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/mixer-a/services/trackbacks/384256.html</trackback:ping><description><![CDATA[<p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">上个月,博客园精华区有篇文章?nbsp;<a target="_blank" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #3d81ee; border-bottom-width: 1px; border-bottom-style: dashed; ">GET ?POST 有什么区别?及ؓ什么网上的多数{案都是错的</a> 》,文中和回复多是对以下两个问题q行了深IӞ</p><ul style="list-style-position: initial; list-style-image: initial; margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 45px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; line-height: 27px; text-align: left; background-color: #fefefe; "><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">长度限制</li><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">Url 是否隐藏数据</li></ul><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">在我看来q两者都不是重点Q特写此文予以讨论?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">我们先来看些基本概念Q?/p><h1>HTTP 基本概念</h1><h2>HTTP Request Methods</h2><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">GET、POST 专业名称?HTTP Request Methods。但 HTTP Request Methods 不只?GET ?POSTQ完整列表如下:</p><ul style="list-style-position: initial; list-style-image: initial; margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 45px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; line-height: 27px; text-align: left; background-color: #fefefe; "><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">GET</li><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">POST</li><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">PUT</li><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">DELETE</li><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">HEAD</li><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">OPTIONS</li><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">TRACE</li><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">CONNECT</li><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">PATCH</li></ul><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">REST 使用前四个:GET、POST、PUT、DELETE。因些这四个也是l常被一块提及的Q将q四个作为关键字q行搜烦Q你会得到更深入的结果?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">在一般的 Web 开发中QGET ?POST 用得最多,|上对这两的讨论也是最多,往往又很肤浅的?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">更多信息h看:</p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">    <a target="_blank" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #3d81ee; border-bottom-width: 1px; border-bottom-style: dashed; ">http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html</a></p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">    <a target="_blank" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #3d81ee; border-bottom-width: 1px; border-bottom-style: dashed; ">http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol</a></p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">    <a target="_blank" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #3d81ee; border-bottom-width: 1px; border-bottom-style: dashed; ">http://zh.wikipedia.org/wiki/REST</a></p><h2>Safe MethodsQ安全方法)</h2><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">RFC 2616 中定义如下(后面有翻译)Q?/p><blockquote style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/bq.gif); background-color: #fefefe; color: #666666; margin-left: auto; padding-left: 45px; padding-right: 0px; padding-top: 0px; padding-bottom: 0px; margin-top: 0px; margin-bottom: 0px; margin-right: auto; font-size: 13px; width: 912px; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-position: 0% 0%; background-repeat: no-repeat no-repeat; "><p style="margin-top: 8px; margin-bottom: 8px; text-indent: 0em; ">Implementors should be aware that the software represents the user in their interactions over the Internet, and should be careful to allow the user to be aware of any actions they might take which may have an unexpected significance to themselves or others.</p><p style="margin-top: 8px; margin-bottom: 8px; text-indent: 0em; ">In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These methods ought to be considered "safe". This allows user agents to represent other methods, such as POST, PUT and DELETE, in a special way, so that the user is made aware of the fact that a possibly unsafe action is being requested.</p><p style="margin-top: 8px; margin-bottom: 8px; text-indent: 0em; ">Naturally, it is not possible to ensure that the server does not generate side-effects as a result of performing a GET request; in fact, some dynamic resources consider that a feature. The important distinction here is that the user did not request the side-effects, so therefore cannot be held accountable for them.</p></blockquote><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">|址Q?a target="_blank" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #3d81ee; border-bottom-width: 1px; border-bottom-style: dashed; ">http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.1.1</a></p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">l基癄中的说明Q对 RFC 2616译Q:</p><blockquote style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/bq.gif); background-color: #fefefe; color: #666666; margin-left: auto; padding-left: 45px; padding-right: 0px; padding-top: 0px; padding-bottom: 0px; margin-top: 0px; margin-bottom: 0px; margin-right: auto; font-size: 13px; width: 912px; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-position: 0% 0%; background-repeat: no-repeat no-repeat; "><p style="margin-top: 8px; margin-bottom: 8px; text-indent: 0em; ">开发者应当意识到他们?a target="_blank" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #3d81ee; border-bottom-width: 1px; border-bottom-style: dashed; ">软g</a>代表了用户在<a target="_blank" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #3d81ee; border-bottom-width: 1px; border-bottom-style: dashed; ">因特|?/a>上进行交互,q且应当告知用户Q他们正在进行的操作可能对他们自w或者其他h有未N料的重要影响?/p><p style="margin-top: 8px; margin-bottom: 8px; text-indent: 0em; ">特别圎ͼ对于GET和HEADҎ而言Q除了进行获取资源信息外Q这些请求不应当再有M其他意义。也是_q些Ҏ应当被认为是“安全?#8221;。客L应当使用其他“非安?#8221;ҎQ例如POSTQPUT及DELETE来以Ҏ的方式(通常是按钮而不?a target="_blank" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #3d81ee; border-bottom-width: 1px; border-bottom-style: dashed; ">链?/a>Q得客戯够意识到可能要负的责任(例如一个按钮带来的资金交易Q或者被告知正在h的操作可能是不安全的Q例如某个文件将被上传或删除Q?/p><p style="margin-top: 8px; margin-bottom: 8px; text-indent: 0em; ">但是Q不能想当然地认为服务器在处理某个GETh时不会生Q何副作用。事实上Q很多动态资源会把这作ؓ其特性。这里重要的区别在于用户q没有请求这一副作用,因此不应q户ؓq些副作用承担责仅R?/p></blockquote><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">来源|址Q?a target="_blank" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #3d81ee; border-bottom-width: 1px; border-bottom-style: dashed; ">http://zh.wikipedia.org/wiki/文本传输协?.E5.AE.89.E5.85.A8.E6.96.B9.E6.B3.95</a></p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">q部分读h比较晦ӆQ不要着急,d后面的再回头看就好理解了?/p><h1>GET ?POST 的区?/h1><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">lg所qͼ可ȝ如下Q?/p><ul style="list-style-position: initial; list-style-image: initial; margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 45px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; line-height: 27px; text-align: left; background-color: #fefefe; "><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">GET 仅用来获取查看信息,不能改变服务器信息?/li><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">POST 用来改变服务器信息?/li></ul><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">q里说的改变Q包括增加、修改和删除?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">q是 HTTP 协议中的要求Q众多浏览器和浏览器插g都遵守这些约定。如果你的代码不按照q约定来Q可能会出现严重的后果?/p><h2>使用 GET 改变服务器信息的严重后果</h2><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">假定你编写的 Web E序或网站允?GET 提交的修改,比如允许用户通过以下 Url 直接删除~写?1024 的订单:</p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">   ~/orders/delete/1024</p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">那么在订单的理Q或列表Q页面,你可能会定义一个删除连接如下:</p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">    <a href="/orders/delete/1024">删除</a></p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">当然不会q么单,一般都会在删除之前会提C用户一下,加上认提示脚本Q?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">    <a href="/orders/delete/1024" onclick="return confirm('实要删除吗Q?)">删除</a></p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">Q说明:我在q里只是C简单例下,d认删除q是使用 Unobtrusive JavaScript 方式Q可以?jQuery。)</p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">很多开发h员以样就万事大吉了,有了认提示Q也不怕误删。但问题恰恰出在这里,2005q时Q谷歌发布了一ƾ浏览器加速插ӞGoogle Web AcceleratorQ以下简U?GWAQ,让这U问题严重的暴露了出来?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">GWA 通过多种技术来加速,其中一U就是页面预先加载:比如你在查看我这文章的时候,GWA 可能把我前一或其它文章预先在后C载,q样你在点击Ӟp省了旉QvC加速的效果?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">GWA 的预先加载是Ҏ当前面中的链接来的Q根?HTTP 的协议,点击链接时?GET Ҏ获取信息Q因些不会对服务器造成影响。因?GWA 会放心的加蝲当前面链接对应的网c当然也可能会加速上面提到的订单删除链接QGWA 会无视你的确认删除脚本,直接从后台把 "/orders/delete/1024" 载入Q也意味着 1024 订单已经被删除了?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">GWA 发布后,很多|站出现了很多莫名其妙的问题Q数据无故丢失,商品自动加入了用L购物车,用户无端地被扣款…</p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">一旉题很严重Q后来发现的原因的所在,是|站开发者没有遵?HTTP U定Q没有弄明白 GET ?POST 的区别?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">可以查看以下文章深入了解q段历史Q?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">   <a target="_blank" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #3d81ee; border-bottom-width: 1px; border-bottom-style: dashed; ">http://blogs.adobe.com/cantrell/archives/2005/06/what_have_we_le.html</a></p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">   <a target="_blank" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #3d81ee; border-bottom-width: 1px; border-bottom-style: dashed; ">http://blog.moertel.com/articles/2005/05/06/google-web-accelerator-offers-web-developers-an-important-opportunity</a></p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">而如今,h发布?Chrome 览器,cM的加速功能集成了q去Q你可以?nbsp;<strong>讄 - 昄高讄</strong> 里面看得刎ͼ</p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; "><a target="_blank" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #3d81ee; border-bottom-width: 1px; border-bottom-style: dashed; "><img title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/ldp615/201207/201207272001342588.png" width="684" height="356" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; background-color: #ffffff; border-top-color: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; background-image: none; border-bottom-style: initial; border-left-style: initial; padding-left: 0px; padding-right: 0px; display: inline; border-top-style: initial; border-right-style: initial; padding-top: 0px; " /></a></p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">所以,Ҏ务器有改变的一定要?POSTQGWA 和类似的插g不会提交 POST 表单加速的?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">删除、查看用户信息收费(比如人才|、婚恋网Q、加入购物R{操作还是放?POST 表单中用 Button 来吧?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">再回头读l基癄中对 Safe Methods 的说明,怿你会明白很多?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">注意Q但也不是所有对服务器有改变的都要用 POSTQ比如你点击本文下面?nbsp;<a target="_blank" style="outline-style: none; outline-width: initial; outline-color: initial; text-decoration: none; color: #3d81ee; border-bottom-width: 1px; border-bottom-style: dashed; ">前一博文链?/a> Q我的文章访问量可能+1Q对服务器有所改变Q但q种改变是轻微的Q媄响不大(相对删除、扣ƾ来_Q可以放心的使用链接QGET 方式Q?/p><h2>基它一些区别:</h2><ul style="list-style-position: initial; list-style-image: initial; margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 45px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; line-height: 27px; text-align: left; background-color: #fefefe; "><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">使用 GET 表单查询Q查询结果页面可以收藏;POST 表单不行?/li><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">向服务器发送文件只能?POST 表单?/li></ul><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">能想到的大致q些吧?/p><h1>感言</h1><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">之前Q我曑֭?ASP.NET 多年Q但?HTTP 几乎一无所知,WebForm 装了一切:</p><ul style="list-style-position: initial; list-style-image: initial; margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 45px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; line-height: 27px; text-align: left; background-color: #fefefe; "><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">不用去考虑 POST、GETQ只需知道 PostbackQ?/li><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">不用多考虑值来回传递,因ؓ?ViewStateQ?/li><li style="background-image: url(http://common.cnblogs.com/Skins/Minyx2_Lite/images/icon_miniarrow.gif); padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 15px; list-style: inherit; background-position: 0px 9px; background-repeat: no-repeat no-repeat; ">不用兛_ HtmlQ因为有服务端控件?/li></ul><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">更悲哀的是Q我有很长一D|间都认ؓ一个页面上只能有一?Form?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">后来做了一D|?WinForm 后,开始学?ASP.NET MVCQ开始逐步了解 Html、Http {等Q也开始知道了 Post-Redirect-Get 模式{等?/p><p style="line-height: 27px; margin-top: 12px; margin-bottom: 12px; color: #333333; font-family: 微Y雅黑, 'Trebuchet MS', Georgia, 'Times New Roman', Times, sans-serif; text-align: left; background-color: #fefefe; ">看到很多人浅讨?GET ?POSTQ感到很无奈QWebForm 误h啊。要惌步,q是学学 ASP.NET MVC 吧!</p><img src ="http://www.aygfsteel.com/mixer-a/aggbug/384256.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/mixer-a/" target="_blank">mixer-a</a> 2012-07-29 10:48 <a href="http://www.aygfsteel.com/mixer-a/archive/2012/07/29/384256.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>抛弃AJAX?! "服务器推"之初体验http://www.aygfsteel.com/mixer-a/archive/2012/07/29/384257.htmlmixer-amixer-aSun, 29 Jul 2012 02:48:00 GMThttp://www.aygfsteel.com/mixer-a/archive/2012/07/29/384257.htmlhttp://www.aygfsteel.com/mixer-a/comments/384257.htmlhttp://www.aygfsteel.com/mixer-a/archive/2012/07/29/384257.html#Feedback1http://www.aygfsteel.com/mixer-a/comments/commentRss/384257.htmlhttp://www.aygfsteel.com/mixer-a/services/trackbacks/384257.html以聊天室Z?说v写聊天室,大家随口都能说出个大?

x隔一D|间向服务器异步请求更斎ͼ用四个字母代替之是AJAX?/p>

 

其实我们转念xQ我们用AJAX的目的就是ə面能实时地更新Q?span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #ff0000; ">倘若我们的动态页面能够实时地更新Q我们干嘛还费这些周折?

 

先看一个小试验Q?/p>

复制代码
1 <?php 2 while(true){ 3         echo 'Hello'; 4         sleep (1000); 5 } 6 ?>
复制代码

如果如我们所愿,则页面将每隔一U都会显CZ?#8216;hello’

 

看到q,也许知道我们聊天室的消息昄面该怎么写了Q请看伪代码?/p>

复制代码
 1 <?php  2 $currentData = getData();  3 while (true){  4       $differences=getData();  5       if ($differences!=$currentData){  6                    echo $differences;  7                    }  8       sleep (10000);  9 } 10 ?>
复制代码

可惜光是q样是不能成功滴Q因为我们还没考虑到php的缓存和~冲问题?/p>

 

php默认会缓存内容,防止http报文的Header和Data分离。且php会缓冲页面内容直至程序结束再页面输出?/p>

 

知道原因好办了。好在php提供了关闭缓冲和~存的方法?/p>

直接在前面加?/p>

1 output_buffering=0 2 ob_end_flush(); 3 set_time_limit(0);

 

则变?

复制代码
 1 <?php  2 output_buffering=0;  3 ob_end_flush();  4   5 while(true){  6         echo 'Hello';  7         sleep (1000);  8         flush(); //强制使PHP输出  9 } 10 ?>
复制代码

你会发现W一个显Chello的已l成功了Q?/p>

我们的消息页面就变ؓ

复制代码
 1 <?php  2 output_buffering=0;  3 ob_end_flush();  4   5 $currentData = getData();  6 while (true){  7       $differences=getData();  8       if ($differences!=$currentData){  9                    echo $differences; 10                    flush(); 11                    } 12       sleep (10000); 13 } 14 ?>
复制代码

 

 

但是在项目最l的实现上,客户端也存在问题Q?/p>

有些览器也会在昄之前Q缓存接收到的内宏V例?nbsp;Netscape 览器会在接受到换行?nbsp;html 标记的开头之前缓存内容,q且在接受到 </table> 标记之前Q不会显C出整个表格?nbsp;

IE甚至只有当接受到?56个字节以后才开始显C面Q所以必d送一些额外的I格来让q些览器显C页面内宏V?/span>

 

x我们已经?#8221;服务器推“解决了的实时更新的问题。其他框架也与普通思\无异Q就不再累述了?/p>

 

有兴的同学可以着手写一个了。呵c?/p>

 

Ƣ迎大家一起交?/p>

mixer-a 2012-07-29 10:48 发表评论
]]>
你应该实现在|站上的30个jQuery插ghttp://www.aygfsteel.com/mixer-a/archive/2012/07/29/384255.htmlmixer-amixer-aSun, 29 Jul 2012 02:46:00 GMThttp://www.aygfsteel.com/mixer-a/archive/2012/07/29/384255.htmlhttp://www.aygfsteel.com/mixer-a/comments/384255.htmlhttp://www.aygfsteel.com/mixer-a/archive/2012/07/29/384255.html#Feedback0http://www.aygfsteel.com/mixer-a/comments/commentRss/384255.htmlhttp://www.aygfsteel.com/mixer-a/services/trackbacks/384255.html阅读全文

mixer-a 2012-07-29 10:46 发表评论
]]>
博客Q我要重新认识你http://www.aygfsteel.com/mixer-a/archive/2012/07/18/383454.htmlmixer-amixer-aWed, 18 Jul 2012 15:41:00 GMThttp://www.aygfsteel.com/mixer-a/archive/2012/07/18/383454.htmlhttp://www.aygfsteel.com/mixer-a/comments/383454.htmlhttp://www.aygfsteel.com/mixer-a/archive/2012/07/18/383454.html#Feedback0http://www.aygfsteel.com/mixer-a/comments/commentRss/383454.htmlhttp://www.aygfsteel.com/mixer-a/services/trackbacks/383454.html阅读全文

mixer-a 2012-07-18 23:41 发表评论
]]>
7月的ַQ你是XXXhttp://www.aygfsteel.com/mixer-a/archive/2012/07/18/383453.htmlmixer-amixer-aWed, 18 Jul 2012 15:40:00 GMThttp://www.aygfsteel.com/mixer-a/archive/2012/07/18/383453.htmlhttp://www.aygfsteel.com/mixer-a/comments/383453.htmlhttp://www.aygfsteel.com/mixer-a/archive/2012/07/18/383453.html#Feedback0http://www.aygfsteel.com/mixer-a/comments/commentRss/383453.htmlhttp://www.aygfsteel.com/mixer-a/services/trackbacks/383453.htmlq里对前半年略作结Q顺带也扯些别的?nbsp; 阅读全文

mixer-a 2012-07-18 23:40 发表评论
]]>
E序员必ȝ道的几个国外IT|站http://www.aygfsteel.com/mixer-a/archive/2012/07/18/383452.htmlmixer-amixer-aWed, 18 Jul 2012 15:39:00 GMThttp://www.aygfsteel.com/mixer-a/archive/2012/07/18/383452.htmlhttp://www.aygfsteel.com/mixer-a/comments/383452.htmlhttp://www.aygfsteel.com/mixer-a/archive/2012/07/18/383452.html#Feedback1http://www.aygfsteel.com/mixer-a/comments/commentRss/383452.htmlhttp://www.aygfsteel.com/mixer-a/services/trackbacks/383452.html阅读全文

mixer-a 2012-07-18 23:39 发表评论
]]>
q行计算框架的Java实现--pd?/title><link>http://www.aygfsteel.com/mixer-a/archive/2012/07/15/383110.html</link><dc:creator>mixer-a</dc:creator><author>mixer-a</author><pubDate>Sat, 14 Jul 2012 17:21:00 GMT</pubDate><guid>http://www.aygfsteel.com/mixer-a/archive/2012/07/15/383110.html</guid><wfw:comment>http://www.aygfsteel.com/mixer-a/comments/383110.html</wfw:comment><comments>http://www.aygfsteel.com/mixer-a/archive/2012/07/15/383110.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/mixer-a/comments/commentRss/383110.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/mixer-a/services/trackbacks/383110.html</trackback:ping><description><![CDATA[<div class="wmqeeuq" id="blog_content" style="line-height: 1.8em; font-family: Helvetica, Tahoma, Arial, sans-serif; text-align: left; background-color: #ffffff; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">增加对结果的处理Q?/p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">1、修改JobQ实现Callable接口</p><div class="wmqeeuq" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; background-color: transparent; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; ">Java代码 <embed wmode="transparent" src="http://shenxueliang.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=public%20abstract%20class%20Job%20implements%20Callable%3CObject%3E%20%7B%0A%0A%09%40Override%0A%09public%20Object%20call()%20throws%20Exception%20%7B%0A%09%09Object%20result%20%3D%20this.execute()%3B%2F%2F%E6%89%A7%E8%A1%8C%E5%AD%90%E7%B1%BB%E5%85%B7%E4%BD%93%E4%BB%BB%E5%8A%A1%0A%09%09synchronized%20(Executer.LOCK)%20%7B%0A%09%09%09%2F%2F%E5%A4%84%E7%90%86%E5%AE%8C%E4%B8%9A%E5%8A%A1%E5%90%8E%EF%BC%8C%E4%BB%BB%E5%8A%A1%E7%BB%93%E6%9D%9F%EF%BC%8C%E9%80%92%E5%87%8F%E7%BA%BF%E7%A8%8B%E6%95%B0%EF%BC%8C%E5%90%8C%E6%97%B6%E5%94%A4%E9%86%92%E4%B8%BB%E7%BA%BF%E7%A8%8B%0A%09%09%09Executer.THREAD_COUNT--%3B%0A%09%09%09Executer.LOCK.notifyAll()%3B%0A%09%09%7D%0A%09%09return%20result%3B%0A%09%7D%0A%09%2F**%0A%09%20*%20%E4%B8%9A%E5%8A%A1%E5%A4%84%E7%90%86%E5%87%BD%E6%95%B0%0A%09%20*%2F%0A%09public%20abstract%20Object%20execute()%3B%0A%0A%7D" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> <a title="收藏q段代码" style="color: #108ac6; "><img src="http://shenxueliang.iteye.com/images/icon_star.png" alt="收藏代码" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; " /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: #7f0055; ">public</span> <span style="color: #7f0055; ">abstract</span> <span style="color: #7f0055; ">class</span> Job <span style="color: #7f0055; ">implements</span> Callable<Object> {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #646464; ">@Override</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> Object call() <span style="color: #7f0055; ">throws</span> Exception {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        Object result = <span style="color: #7f0055; ">this</span>.execute();//执行子类具体d  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">synchronized</span> (Executer.LOCK) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            //处理完业务后QQ务结束,递减U程敎ͼ同时唤醒ȝE?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            Executer.THREAD_COUNT--;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            Executer.LOCK.notifyAll();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">return</span> result;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    /** </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     * 业务处理函数 </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     */  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> <span style="color: #7f0055; ">abstract</span> Object execute();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">}  </li></ol></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "> </p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">2、修改ExecuterQ增加对l果的处?/p><div class="wmqeeuq" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; background-color: transparent; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; ">Java代码 <embed wmode="transparent" src="http://shenxueliang.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=public%20class%20Executer%20%7B%0A%09%2F%2F%E8%AE%A1%E7%AE%97%E5%B7%B2%E7%BB%8F%E6%B4%BE%E5%8F%91%E7%9A%84%E4%BB%BB%E5%8A%A1%E6%95%B0(%E6%9D%A1%E4%BB%B6%E8%B0%93%E8%AF%8D)%0A%09public%20static%20int%20THREAD_COUNT%20%3D%200%3B%0A%09%2F%2F%E5%AD%98%E5%82%A8%E4%BB%BB%E5%8A%A1%E7%9A%84%E6%89%A7%E8%A1%8C%E7%BB%93%E6%9E%9C%0A%09private%20List%3CFuture%3CObject%3E%3E%20futres%20%3D%20new%20ArrayList%3CFuture%3CObject%3E%3E()%3B%20%0A%09%2F%2F%E6%9D%A1%E4%BB%B6%E9%98%9F%E5%88%97%E9%94%81%0A%09public%20static%20final%20Object%20LOCK%20%3D%20new%20Object()%3B%0A%09%2F%2F%E7%BA%BF%E7%A8%8B%E6%B1%A0%0A%09private%20ExecutorService%20pool%20%3D%20null%3B%0A%09public%20Executer()%20%7B%0A%09%09this(1)%3B%0A%09%7D%0A%09public%20Executer(int%20threadPoolSize)%20%7B%0A%09%09pool%20%3D%20Executors.newFixedThreadPool(threadPoolSize)%3B%0A%09%7D%0A%09%2F**%0A%09%20*%20%E4%BB%BB%E5%8A%A1%E6%B4%BE%E5%8F%91%0A%09%20*%20%40param%20job%0A%09%20*%2F%0A%09public%20void%20fork(Job%20job)%7B%0A%09%09%2F%2F%E5%B0%86%E4%BB%BB%E5%8A%A1%E6%B4%BE%E5%8F%91%E7%BB%99%E7%BA%BF%E7%A8%8B%E6%B1%A0%E5%8E%BB%E6%89%A7%E8%A1%8C%0A%09%09futres.add(pool.submit(job))%3B%0A%09%09%2F%2F%E5%A2%9E%E5%8A%A0%E7%BA%BF%E7%A8%8B%E6%95%B0%0A%09%09synchronized%20(LOCK)%20%7B%0A%09%09%09THREAD_COUNT%2B%2B%3B%0A%09%09%7D%0A%09%7D%0A%09%2F**%0A%09%20*%20%E7%BB%9F%E8%AE%A1%E4%BB%BB%E5%8A%A1%E7%BB%93%E6%9E%9C%0A%09%20*%2F%0A%09public%20List%3CObject%3E%20join()%7B%0A%09%09synchronized%20(LOCK)%20%7B%0A%09%09%09while(THREAD_COUNT%20%3E%200)%7B%2F%2F%E6%A3%80%E6%9F%A5%E7%BA%BF%E7%A8%8B%E6%95%B0%EF%BC%8C%E5%A6%82%E6%9E%9C%E4%B8%BA0%EF%BC%8C%E5%88%99%E8%A1%A8%E7%A4%BA%E6%89%80%E6%9C%89%E4%BB%BB%E5%8A%A1%E5%A4%84%E7%90%86%E5%AE%8C%E6%88%90%0A%09%09%09%09System.out.println(%22threadCount%3A%20%22%2BTHREAD_COUNT)%3B%0A%09%09%09%09try%20%7B%0A%09%09%09%09%09LOCK.wait()%3B%2F%2F%E5%A6%82%E6%9E%9C%E4%BB%BB%E5%8A%A1%E6%B2%A1%E6%9C%89%E5%85%A8%E9%83%A8%E5%AE%8C%E6%88%90%EF%BC%8C%E5%88%99%E6%8C%82%E8%B5%B7%E3%80%82%E7%AD%89%E5%BE%85%E5%AE%8C%E6%88%90%E7%9A%84%E4%BB%BB%E5%8A%A1%E7%BB%99%E4%BA%88%E9%80%9A%E7%9F%A5%0A%09%09%09%09%7D%20catch%20(InterruptedException%20e)%20%7B%0A%09%09%09%09%09e.printStackTrace()%3B%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09List%3CObject%3E%20list%20%3D%20new%20ArrayList%3CObject%3E()%3B%0A%09%09%2F%2F%E5%8F%96%E5%87%BA%E6%AF%8F%E4%B8%AA%E4%BB%BB%E5%8A%A1%E7%9A%84%E5%A4%84%E7%90%86%E7%BB%93%E6%9E%9C%EF%BC%8C%E6%B1%87%E6%80%BB%E5%90%8E%E8%BF%94%E5%9B%9E%0A%09%09for%20(Future%3CObject%3E%20future%20%3A%20futres)%20%7B%0A%09%09%09try%20%7B%0A%09%09%09%09Object%20result%20%3D%20future.get()%3B%2F%2F%E5%9B%A0%E4%B8%BA%E4%BB%BB%E5%8A%A1%E9%83%BD%E5%B7%B2%E7%BB%8F%E5%AE%8C%E6%88%90%EF%BC%8C%E8%BF%99%E9%87%8C%E7%9B%B4%E6%8E%A5get%0A%09%09%09%09list.add(result)%3B%0A%09%09%09%7D%20catch%20(Exception%20e)%20%7B%0A%09%09%09%09e.printStackTrace()%3B%0A%09%09%09%7D%20%0A%09%09%7D%0A%09%09return%20list%3B%0A%09%7D%0A%7D" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> <a title="收藏q段代码" style="color: #108ac6; "><img src="http://shenxueliang.iteye.com/images/icon_star.png" alt="收藏代码" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; " /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: #7f0055; ">public</span> <span style="color: #7f0055; ">class</span> Executer {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    //计算已经z֏的Q务数(条g谓词)  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> <span style="color: #7f0055; ">static</span> <span style="color: #7f0055; ">int</span> THREAD_COUNT = <span style="color: #c00000; ">0</span>;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    //存储d的执行结?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">private</span> List<Future<Object>> futres = <span style="color: #7f0055; ">new</span> ArrayList<Future<Object>>();   </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    //条g队列?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> <span style="color: #7f0055; ">static</span> <span style="color: #7f0055; ">final</span> Object LOCK = <span style="color: #7f0055; ">new</span> Object();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    //U程?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">private</span> ExecutorService pool = <span style="color: #7f0055; ">null</span>;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> Executer() {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">this</span>(<span style="color: #c00000; ">1</span>);  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> Executer(<span style="color: #7f0055; ">int</span> threadPoolSize) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        pool = Executors.newFixedThreadPool(threadPoolSize);  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    /** </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     * dz֏ </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     * @param job </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     */  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> <span style="color: #7f0055; ">void</span> fork(Job job){  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        //Q务派发给U程池去执行  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        futres.add(pool.submit(job));  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        //增加U程?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">synchronized</span> (LOCK) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            THREAD_COUNT++;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    /** </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     * l计dl果 </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     */  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> List<Object> join(){  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">synchronized</span> (LOCK) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            <span style="color: #7f0055; ">while</span>(THREAD_COUNT > <span style="color: #c00000; ">0</span>){//查线E数Q如果ؓ0Q则表示所有Q务处理完?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                System.out.println("threadCount: "+THREAD_COUNT);  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                <span style="color: #7f0055; ">try</span> {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                    LOCK.wait();//如果d没有全部完成Q则挂v。等待完成的dl予通知  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                } <span style="color: #7f0055; ">catch</span> (InterruptedException e) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                    e.printStackTrace();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        List<Object> list = <span style="color: #7f0055; ">new</span> ArrayList<Object>();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        //取出每个d的处理结果,汇dq回  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">for</span> (Future<Object> future : futres) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            <span style="color: #7f0055; ">try</span> {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                Object result = future.get();//因ؓd都已l完成,q里直接get  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                list.add(result);  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            } <span style="color: #7f0055; ">catch</span> (Exception e) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                e.printStackTrace();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            }   </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">return</span> list;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">}  </li></ol></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "> </p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "> 3、测试:</p><div class="wmqeeuq" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; background-color: transparent; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; ">Java代码 <embed wmode="transparent" src="http://shenxueliang.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=public%20static%20void%20main(String%5B%5D%20args)%20%7B%0A%09%09%2F%2F%E5%88%9D%E5%A7%8B%E5%8C%96%E4%BB%BB%E5%8A%A1%E6%B1%A0%0A%09%09Executer%20exe%20%3D%20new%20Executer(5)%3B%0A%09%09%2F%2F%E5%88%9D%E5%A7%8B%E5%8C%96%E4%BB%BB%E5%8A%A1%0A%09%09long%20time%20%3D%20System.currentTimeMillis()%3B%0A%09%09for%20(int%20i%20%3D%200%3B%20i%20%3C%2010%3B%20i%2B%2B)%20%7B%0A%09%09%09MyJob%20job%20%3D%20new%20MyJob()%3B%0A%09%09%09exe.fork(job)%3B%2F%2F%E6%B4%BE%E5%8F%91%E4%BB%BB%E5%8A%A1%0A%09%09%7D%0A%09%09%2F%2F%E6%B1%87%E6%80%BB%E4%BB%BB%E5%8A%A1%E7%BB%93%E6%9E%9C%0A%09%09List%3CObject%3E%20list%20%3D%20exe.join()%3B%0A%09%09System.out.println(%22Result%3A%20%22%2Blist)%3B%0A%09%09System.out.println(%22time%3A%20%22%2B(System.currentTimeMillis()%20-%20time))%3B%0A%09%7D" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> <a title="收藏q段代码" style="color: #108ac6; "><img src="http://shenxueliang.iteye.com/images/icon_star.png" alt="收藏代码" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; " /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: #7f0055; ">public</span> <span style="color: #7f0055; ">static</span> <span style="color: #7f0055; ">void</span> main(String[] args) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        //初始化Q务池  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        Executer exe = <span style="color: #7f0055; ">new</span> Executer(<span style="color: #c00000; ">5</span>);  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        //初始化Q?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">long</span> time = System.currentTimeMillis();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">for</span> (<span style="color: #7f0055; ">int</span> i = <span style="color: #c00000; ">0</span>; i < <span style="color: #c00000; ">10</span>; i++) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            MyJob job = <span style="color: #7f0055; ">new</span> MyJob();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            exe.fork(job);//z֏d  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        //汇MQ务结?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        List<Object> list = exe.join();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        System.out.println("Result: "+list);  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        System.out.println("time: "+(System.currentTimeMillis() - time));  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    }  </li></ol></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "> </p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">4、执行结果:</p><div class="wmqeeuq" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; background-color: transparent; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; ">Java代码 <embed wmode="transparent" src="http://shenxueliang.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=threadCount%3A%2010%0Arunning%20thread%20id%20%3D%209%0Arunning%20thread%20id%20%3D%2011%0Arunning%20thread%20id%20%3D%208%0Arunning%20thread%20id%20%3D%2010%0Arunning%20thread%20id%20%3D%2012%0AthreadCount%3A%205%0Arunning%20thread%20id%20%3D%209%0Arunning%20thread%20id%20%3D%208%0Arunning%20thread%20id%20%3D%2011%0Arunning%20thread%20id%20%3D%2012%0Arunning%20thread%20id%20%3D%2010%0AResult%3A%20%5B8%2C%209%2C%2010%2C%2011%2C%2012%2C%208%2C%2011%2C%2012%2C%209%2C%2010%5D%0Atime%3A%202000" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> <a title="收藏q段代码" style="color: #108ac6; "><img src="http://shenxueliang.iteye.com/images/icon_star.png" alt="收藏代码" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; " /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">threadCount: <span style="color: #c00000; ">10</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">9</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">11</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">8</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">10</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">12</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">threadCount: <span style="color: #c00000; ">5</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">9</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">8</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">11</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">12</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">10</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">Result: [<span style="color: #c00000; ">8</span>, <span style="color: #c00000; ">9</span>, <span style="color: #c00000; ">10</span>, <span style="color: #c00000; ">11</span>, <span style="color: #c00000; ">12</span>, <span style="color: #c00000; ">8</span>, <span style="color: #c00000; ">11</span>, <span style="color: #c00000; ">12</span>, <span style="color: #c00000; ">9</span>, <span style="color: #c00000; ">10</span>]  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">time: <span style="color: #c00000; ">2000</span>  </li></ol></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "> </p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">5、附件是完整代码</p></div><div style="border-top-width: 1px; border-top-style: solid; border-top-color: #999999; margin-top: 10px; font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 12px; line-height: 18px; text-align: left; background-color: #ffffff; "><ul style="margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; list-style-type: none; list-style-position: initial; list-style-image: initial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; border-image: initial; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.25em; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><a style="color: #108ac6; ">src.rar</a> (2.2 KB)</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.25em; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">下蝲ơ数: 11</li></ul></div><img src ="http://www.aygfsteel.com/mixer-a/aggbug/383110.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/mixer-a/" target="_blank">mixer-a</a> 2012-07-15 01:21 <a href="http://www.aygfsteel.com/mixer-a/archive/2012/07/15/383110.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>q行计算框架的Java实现--pd?/title><link>http://www.aygfsteel.com/mixer-a/archive/2012/07/15/383111.html</link><dc:creator>mixer-a</dc:creator><author>mixer-a</author><pubDate>Sat, 14 Jul 2012 17:21:00 GMT</pubDate><guid>http://www.aygfsteel.com/mixer-a/archive/2012/07/15/383111.html</guid><wfw:comment>http://www.aygfsteel.com/mixer-a/comments/383111.html</wfw:comment><comments>http://www.aygfsteel.com/mixer-a/archive/2012/07/15/383111.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/mixer-a/comments/commentRss/383111.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/mixer-a/services/trackbacks/383111.html</trackback:ping><description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">优化锁,之前的锁是采用一个static的Object实现的,q要׃有一个问题,如果我创Z多个ExecuterQ那么所有Job都会持有一把锁Q既影响性能Q也Ҏ出现死锁的情c所以,Ҏ每个Executer持有一把锁?/p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">Executer代码如下Q?/p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; "> </p><div class="wmqeeuq" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; background-color: #ffffff; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; line-height: 25px; text-align: left; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; ">Java代码 <embed wmode="transparent" src="http://shenxueliang.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=public%20class%20Executer%20%7B%0A%09%2F%2F%E8%AE%A1%E7%AE%97%E5%B7%B2%E7%BB%8F%E6%B4%BE%E5%8F%91%E7%9A%84%E4%BB%BB%E5%8A%A1%E6%95%B0(%E6%9D%A1%E4%BB%B6%E8%B0%93%E8%AF%8D)%0A%09public%20static%20int%20THREAD_COUNT%20%3D%200%3B%0A%09%2F%2F%E5%AD%98%E5%82%A8%E4%BB%BB%E5%8A%A1%E7%9A%84%E6%89%A7%E8%A1%8C%E7%BB%93%E6%9E%9C%0A%09private%20List%3CFuture%3CObject%3E%3E%20futres%20%3D%20new%20ArrayList%3CFuture%3CObject%3E%3E()%3B%20%0A%09%2F%2F%E6%9D%A1%E4%BB%B6%E9%98%9F%E5%88%97%E9%94%81%0A%09public%20final%20Object%20lock%20%3D%20new%20Object()%3B%0A%09%2F%2F%E7%BA%BF%E7%A8%8B%E6%B1%A0%0A%09private%20ExecutorService%20pool%20%3D%20null%3B%0A%09public%20Executer()%20%7B%0A%09%09this(1)%3B%0A%09%7D%0A%09public%20Executer(int%20threadPoolSize)%20%7B%0A%09%09pool%20%3D%20Executors.newFixedThreadPool(threadPoolSize)%3B%0A%09%7D%0A%09%2F**%0A%09%20*%20%E4%BB%BB%E5%8A%A1%E6%B4%BE%E5%8F%91%0A%09%20*%20%40param%20job%0A%09%20*%2F%0A%09public%20void%20fork(Job%20job)%7B%0A%09%09%2F%2F%E8%AE%BE%E7%BD%AE%E5%90%8C%E6%AD%A5%E9%94%81%0A%09%09job.setLock(lock)%3B%0A%09%09%2F%2F%E5%B0%86%E4%BB%BB%E5%8A%A1%E6%B4%BE%E5%8F%91%E7%BB%99%E7%BA%BF%E7%A8%8B%E6%B1%A0%E5%8E%BB%E6%89%A7%E8%A1%8C%0A%09%09futres.add(pool.submit(job))%3B%0A%09%09%2F%2F%E5%A2%9E%E5%8A%A0%E7%BA%BF%E7%A8%8B%E6%95%B0%0A%09%09synchronized%20(lock)%20%7B%0A%09%09%09THREAD_COUNT%2B%2B%3B%0A%09%09%7D%0A%09%7D%0A%09%2F**%0A%09%20*%20%E7%BB%9F%E8%AE%A1%E4%BB%BB%E5%8A%A1%E7%BB%93%E6%9E%9C%0A%09%20*%2F%0A%09public%20List%3CObject%3E%20join()%7B%0A%09%09synchronized%20(lock)%20%7B%0A%09%09%09while(THREAD_COUNT%20%3E%200)%7B%2F%2F%E6%A3%80%E6%9F%A5%E7%BA%BF%E7%A8%8B%E6%95%B0%EF%BC%8C%E5%A6%82%E6%9E%9C%E4%B8%BA0%EF%BC%8C%E5%88%99%E8%A1%A8%E7%A4%BA%E6%89%80%E6%9C%89%E4%BB%BB%E5%8A%A1%E5%A4%84%E7%90%86%E5%AE%8C%E6%88%90%0A%09%09%09%09System.out.println(%22threadCount%3A%20%22%2BTHREAD_COUNT)%3B%0A%09%09%09%09try%20%7B%0A%09%09%09%09%09lock.wait()%3B%2F%2F%E5%A6%82%E6%9E%9C%E4%BB%BB%E5%8A%A1%E6%B2%A1%E6%9C%89%E5%85%A8%E9%83%A8%E5%AE%8C%E6%88%90%EF%BC%8C%E5%88%99%E6%8C%82%E8%B5%B7%E3%80%82%E7%AD%89%E5%BE%85%E5%AE%8C%E6%88%90%E7%9A%84%E4%BB%BB%E5%8A%A1%E7%BB%99%E4%BA%88%E9%80%9A%E7%9F%A5%0A%09%09%09%09%7D%20catch%20(InterruptedException%20e)%20%7B%0A%09%09%09%09%09e.printStackTrace()%3B%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09List%3CObject%3E%20list%20%3D%20new%20ArrayList%3CObject%3E()%3B%0A%09%09%2F%2F%E5%8F%96%E5%87%BA%E6%AF%8F%E4%B8%AA%E4%BB%BB%E5%8A%A1%E7%9A%84%E5%A4%84%E7%90%86%E7%BB%93%E6%9E%9C%EF%BC%8C%E6%B1%87%E6%80%BB%E5%90%8E%E8%BF%94%E5%9B%9E%0A%09%09for%20(Future%3CObject%3E%20future%20%3A%20futres)%20%7B%0A%09%09%09try%20%7B%0A%09%09%09%09Object%20result%20%3D%20future.get()%3B%2F%2F%E5%9B%A0%E4%B8%BA%E4%BB%BB%E5%8A%A1%E9%83%BD%E5%B7%B2%E7%BB%8F%E5%AE%8C%E6%88%90%EF%BC%8C%E8%BF%99%E9%87%8C%E7%9B%B4%E6%8E%A5get%0A%09%09%09%09list.add(result)%3B%0A%09%09%09%7D%20catch%20(Exception%20e)%20%7B%0A%09%09%09%09e.printStackTrace()%3B%0A%09%09%09%7D%20%0A%09%09%7D%0A%09%09return%20list%3B%0A%09%7D%0A%7D" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> <a title="收藏q段代码" style="color: #108ac6; "><img src="http://shenxueliang.iteye.com/images/icon_star.png" alt="收藏代码" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; " /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: #7f0055; ">public</span> <span style="color: #7f0055; ">class</span> Executer {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    //计算已经z֏的Q务数(条g谓词)  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> <span style="color: #7f0055; ">static</span> <span style="color: #7f0055; ">int</span> THREAD_COUNT = <span style="color: #c00000; ">0</span>;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    //存储d的执行结?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">private</span> List<Future<Object>> futres = <span style="color: #7f0055; ">new</span> ArrayList<Future<Object>>();   </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    //条g队列?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> <span style="color: #7f0055; ">final</span> Object lock = <span style="color: #7f0055; ">new</span> Object();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    //U程?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">private</span> ExecutorService pool = <span style="color: #7f0055; ">null</span>;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> Executer() {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">this</span>(<span style="color: #c00000; ">1</span>);  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> Executer(<span style="color: #7f0055; ">int</span> threadPoolSize) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        pool = Executors.newFixedThreadPool(threadPoolSize);  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    /** </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     * dz֏ </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     * @param job </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     */  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> <span style="color: #7f0055; ">void</span> fork(Job job){  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        //讄同步?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        job.setLock(lock);  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        //Q务派发给U程池去执行  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        futres.add(pool.submit(job));  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        //增加U程?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">synchronized</span> (lock) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            THREAD_COUNT++;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    /** </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     * l计dl果 </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     */  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> List<Object> join(){  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">synchronized</span> (lock) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            <span style="color: #7f0055; ">while</span>(THREAD_COUNT > <span style="color: #c00000; ">0</span>){//查线E数Q如果ؓ0Q则表示所有Q务处理完?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                System.out.println("threadCount: "+THREAD_COUNT);  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                <span style="color: #7f0055; ">try</span> {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                    lock.wait();//如果d没有全部完成Q则挂v。等待完成的dl予通知  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                } <span style="color: #7f0055; ">catch</span> (InterruptedException e) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                    e.printStackTrace();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        List<Object> list = <span style="color: #7f0055; ">new</span> ArrayList<Object>();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        //取出每个d的处理结果,汇dq回  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">for</span> (Future<Object> future : futres) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            <span style="color: #7f0055; ">try</span> {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                Object result = future.get();//因ؓd都已l完成,q里直接get  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                list.add(result);  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            } <span style="color: #7f0055; ">catch</span> (Exception e) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">                e.printStackTrace();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            }   </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">return</span> list;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">}  </li></ol></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; "> Jobc?</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; "> </p><div class="wmqeeuq" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; background-color: #ffffff; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; line-height: 25px; text-align: left; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; ">Java代码 <embed wmode="transparent" src="http://shenxueliang.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=public%20abstract%20class%20Job%20implements%20Callable%3CObject%3E%20%7B%0A%0A%09%2F%2F%E9%94%81%0A%09private%20Object%20lock%20%3D%20null%3B%0A%0A%09void%20setLock(Object%20lock)%20%7B%0A%09%09this.lock%20%3D%20lock%3B%0A%09%7D%0A%0A%09%40Override%0A%09public%20Object%20call()%20throws%20Exception%20%7B%0A%09%09Object%20result%20%3D%20this.execute()%3B%2F%2F%E6%89%A7%E8%A1%8C%E5%AD%90%E7%B1%BB%E5%85%B7%E4%BD%93%E4%BB%BB%E5%8A%A1%0A%09%09synchronized%20(lock)%20%7B%0A%09%09%09%2F%2F%E5%A4%84%E7%90%86%E5%AE%8C%E4%B8%9A%E5%8A%A1%E5%90%8E%EF%BC%8C%E4%BB%BB%E5%8A%A1%E7%BB%93%E6%9D%9F%EF%BC%8C%E9%80%92%E5%87%8F%E7%BA%BF%E7%A8%8B%E6%95%B0%EF%BC%8C%E5%90%8C%E6%97%B6%E5%94%A4%E9%86%92%E4%B8%BB%E7%BA%BF%E7%A8%8B%0A%09%09%09Executer.THREAD_COUNT--%3B%0A%09%09%09lock.notifyAll()%3B%0A%09%09%7D%0A%09%09return%20result%3B%0A%09%7D%0A%09%2F**%0A%09%20*%20%E4%B8%9A%E5%8A%A1%E5%A4%84%E7%90%86%E5%87%BD%E6%95%B0%0A%09%20*%2F%0A%09public%20abstract%20Object%20execute()%3B%0A%09%0A%7D" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> <a title="收藏q段代码" style="color: #108ac6; "><img src="http://shenxueliang.iteye.com/images/icon_star.png" alt="收藏代码" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; " /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: #7f0055; ">public</span> <span style="color: #7f0055; ">abstract</span> <span style="color: #7f0055; ">class</span> Job <span style="color: #7f0055; ">implements</span> Callable<Object> {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    //?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">private</span> Object lock = <span style="color: #7f0055; ">null</span>;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">void</span> setLock(Object lock) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">this</span>.lock = lock;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #646464; ">@Override</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> Object call() <span style="color: #7f0055; ">throws</span> Exception {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        Object result = <span style="color: #7f0055; ">this</span>.execute();//执行子类具体d  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">synchronized</span> (lock) {  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            //处理完业务后QQ务结束,递减U程敎ͼ同时唤醒ȝE?nbsp; </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            Executer.THREAD_COUNT--;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">            lock.notifyAll();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">        <span style="color: #7f0055; ">return</span> result;  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    }  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    /** </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     * 业务处理函数 </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">     */  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">    <span style="color: #7f0055; ">public</span> <span style="color: #7f0055; ">abstract</span> Object execute();  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">      </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">}  </li></ol></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; "> 试l果Q?/p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; "> </p><div class="wmqeeuq" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; background-color: #ffffff; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; line-height: 25px; text-align: left; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; ">Java代码 <embed wmode="transparent" src="http://shenxueliang.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=threadCount%3A%2010%0Arunning%20thread%20id%20%3D%208%0Arunning%20thread%20id%20%3D%2010%0Arunning%20thread%20id%20%3D%209%0Arunning%20thread%20id%20%3D%2012%0Arunning%20thread%20id%20%3D%2011%0AthreadCount%3A%208%0AthreadCount%3A%207%0AthreadCount%3A%206%0AthreadCount%3A%205%0Arunning%20thread%20id%20%3D%2012%0Arunning%20thread%20id%20%3D%208%0Arunning%20thread%20id%20%3D%2011%0AthreadCount%3A%202%0Arunning%20thread%20id%20%3D%2010%0AthreadCount%3A%201%0Arunning%20thread%20id%20%3D%209%0AResultSize%3A%2010%0Atime%3A%202001" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> <a title="收藏q段代码" style="color: #108ac6; "><img src="http://shenxueliang.iteye.com/images/icon_star.png" alt="收藏代码" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; " /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">threadCount: <span style="color: #c00000; ">10</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">8</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">10</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">9</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">12</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">11</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">threadCount: <span style="color: #c00000; ">8</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">threadCount: <span style="color: #c00000; ">7</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">threadCount: <span style="color: #c00000; ">6</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">threadCount: <span style="color: #c00000; ">5</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">12</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">8</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">11</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">threadCount: <span style="color: #c00000; ">2</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">10</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">threadCount: <span style="color: #c00000; ">1</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">running thread id = <span style="color: #c00000; ">9</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">ResultSize: <span style="color: #c00000; ">10</span>  </li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">time: <span style="color: #c00000; ">2001</span>  </li></ol></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; "> OKQ?/p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">q样每个Executer可以用自qlockQ而相互不受同步的影响</p><img src ="http://www.aygfsteel.com/mixer-a/aggbug/383111.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/mixer-a/" target="_blank">mixer-a</a> 2012-07-15 01:21 <a href="http://www.aygfsteel.com/mixer-a/archive/2012/07/15/383111.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ľ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">̨</a>| <a href="http://" target="_blank">Һ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˱</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˳</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ѩ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">IJ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̨</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ʯɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>