﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-coolbar</title><link>http://www.blogjava.net/coolbar/</link><description /><language>zh-cn</language><lastBuildDate>Wed, 22 Apr 2026 04:48:53 GMT</lastBuildDate><pubDate>Wed, 22 Apr 2026 04:48:53 GMT</pubDate><ttl>60</ttl><item><title>创建Java中的线程池</title><link>http://www.blogjava.net/coolbar/archive/2005/08/04/9201.html</link><dc:creator>专注java分布式</dc:creator><author>专注java分布式</author><pubDate>Thu, 04 Aug 2005 06:19:00 GMT</pubDate><guid>http://www.blogjava.net/coolbar/archive/2005/08/04/9201.html</guid><wfw:comment>http://www.blogjava.net/coolbar/comments/9201.html</wfw:comment><comments>http://www.blogjava.net/coolbar/archive/2005/08/04/9201.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/coolbar/comments/commentRss/9201.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/coolbar/services/trackbacks/9201.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="BACKGROUND: #f7f7f7; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan" align=left><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">转载：转载请保留本信息，本文来自</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"><A href="http://www.matrix.org.cn/resource/article/194.html"><SPAN style="COLOR: #00659c; TEXT-DECORATION: none; mso-bidi-font-size: 12.0pt; text-underline: none">http://www.matrix.org.cn/resource/article/194.html</SPAN></A> <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="BACKGROUND: #f7f7f7; MARGIN: 0cm 0cm 0pt; WORD-BREAK: break-all; LINE-HEIGHT: 150%; TEXT-ALIGN: left; mso-pagination: widow-orphan" align=left><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">线程是</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Java</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">的一大特性，它可以是给定的指令序列、给定的方法中定义的变量或者一些共享数据</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">(</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">类一级的变量</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">)</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">。在</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Java</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">中每个线程有自己的堆栈和程序计数器（</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">PC</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">），其中堆栈是用来跟踪线程的上下文（上下文是当线程执行到某处时，当前的局部变量的值），而程序计数器则用来跟踪当前线程正在执行的指令。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">在通常情况下，一个线程不能访问另外一个线程的堆栈变量，而且这个线程必须处于如下状态之一：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <BR><BR>1.</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">排队状态（</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Ready</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">），在用户创建了一个线程以后，这个线程不会立即运行。当线程中的方法</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">start()</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">被调用时，这个线程就会进行排队状态，等待调度程序将它转入运行状态（</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Running</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">）。当一个进程被执行后它也可以进行排队状态。如果调度程序允许的话，通过调用方法</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">yield()</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">就可以将进程放入排队状态。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <BR><BR>2.</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">运行状态</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">(Running)</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">，当调度程序将</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">CPU</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">的运行时间分配给一个线程，这个线程就进入了运行状态开始运行。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <BR><BR>3.</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">等待状态（</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Waiting</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">），很多原因都可以导致线程处于等待状态，例如线程执行过程中被暂停，或者是等待</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">I/O</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">请求的完成而进入等待状态。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">在</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Java</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">中不同的线程具有不同的优先级，高优先级的线程可以安排在低优先级线程之前完成。如果多个线程具有相同的优先级，</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Java</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">会在不同的线程之间切换运行。一个应用程序可以通过使用线程中的方法</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">setPriority()</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">来设置线程的优先级，使用方法</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">getPriority()</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">来获得一个线程的优先级。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <BR><BR><BR></SPAN><B><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">线程的生命周期</SPAN></B><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"><BR><BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">一个线程的的生命周期可以分成两阶段：生存（</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Alive</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">）周期和死亡（</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Dead</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">）周期，其中生存周期又包括运行状态（</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Running</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">）和等待状态（</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Waiting</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">）。当创建一个新线程后，这个线程就进入了排队状态（</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Ready</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">），当线程中的方法</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">start()</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">被调用时，线程就进入生存周期，这时它的方法</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">isAlive()</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">始终返回真值，直至线程进入死亡状态。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <BR><BR><BR></SPAN><B><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">线程的实现</SPAN></B><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"><BR><BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">有两种方法可以实现线程，一种是扩展</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">java.lang.Thread</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">类，另一种是通过</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">java.lang.Runnable</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">接口。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <BR><BR>Thread</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">类封装了线程的行为。要创建一个线程，必须创建一个从</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Thread</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">类扩展出的新类。由于在</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Thread</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">类中方法</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">run()</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">没有提供任何的操作，因此，在创建线程时用户必须覆盖方法</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">run()</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">来完成有用的工作。当线程中的方法</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">start()</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">被调用时，方法</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">run()</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">再被调用。下面的代码就是通过扩展</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Thread</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">类来实现线程：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <BR><BR>import java.awt.*;<BR>class Sample1{<BR>public static void main(String[] args){<BR>Mythread test1=new Mythread(1);<BR>Mythread test2=new Mythread(2);<BR>test1.start();<BR>test2.start();<BR>}<BR>}<BR>class Mythread extends Thread {<BR>int id;<BR>Mythread(int i)<BR>{ id=i;}<BR>public void run() {<BR>int i=0;<BR>while(id+i==1){<BR>try {sleep(1000);<BR>} catch(InterruptedException e) {}<BR>}<BR>System.out.println(“The id is ”+id);<BR>}<BR><BR><BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">通常当用户希望一个类能运行在自己的线程中，同时也扩展其它某些类的特性时，就需要借助运行</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Runnable</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">接口来实现。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Runnable</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">接口只有一个方法</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">run()</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">。不论什么时候创建了一个使用</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Runnable</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">接口的类，都必须在类中编写</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">run()</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">方法来覆盖接口中的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">run()</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">方法。例如下面的代码就是通过</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Runnable</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">接口实现的线程：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <BR><BR>import java.awt.*;<BR>import java.applet.Applet;<BR>public class Bounce extends Applet implements Runnable{<BR>static int r=30;<BR>static int x=100;<BR>static int y=30;<BR>Thread t; <BR>public void init()<BR>{<BR>t = new Thread(this);<BR>t.start();<BR>}<BR>public void run() <BR>{<BR>int y1=+1; <BR>int i=1;<BR>int sleeptime=10;<BR>while(true)<BR>{<BR>y+=(i*y); <BR>if(y-r&lt;i ||y+r&gt;getSize().height) <BR>y1*=-1;<BR>try{<BR>t.sleep(sleeptime);<BR>}catch(InterruptedException e){ }<BR>}<BR>}<BR>}<BR><BR><BR><BR><BR></SPAN><B><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">为什么要使用线程池</SPAN></B><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"><BR><BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">在</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Java</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">中，如果每当一个请求到达就创建一个新线程，开销是相当大的。在实际使用中，每个请求创建新线程的服务器在创建和销毁线程上花费的时间和消耗的系统资源，甚至可能要比花在处理实际的用户请求的时间和资源要多得多。除了创建和销毁线程的开销之外，活动的线程也需要消耗系统资源。如果在一个</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">JVM</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">里创建太多的线程，可能会导致系统由于过度消耗内存或</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">“</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">切换过度</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">”</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">而导致系统资源不足。为了防止资源不足，服务器应用程序需要一些办法来限制任何给定时刻处理的请求数目，尽可能减少创建和销毁线程的次数，特别是一些资源耗费比较大的线程的创建和销毁，尽量利用已有对象来进行服务，这就是</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">“</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">池化资源</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">”</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">技术产生的原因。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">线程池主要用来解决线程生命周期开销问题和资源不足问题。通过对多个任务重用线程，线程创建的开销就被分摊到了多个任务上了，而且由于在请求到达时线程已经存在，所以消除了线程创建所带来的延迟。这样，就可以立即为请求服务，使应用程序响应更快。另外，通过适当地调整线程池中的线程数目可以防止出现资源不足的情况。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <BR><BR><BR></SPAN><B><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">创建一个线程池</SPAN></B><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"><BR><BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">一个比较简单的线程池至少应包含线程池管理器、工作线程、任务队列、任务接口等部分。其中线程池管理器（</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">ThreadPool Manager</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">）的作用是创建、销毁并管理线程池，将工作线程放入线程池中；工作线程是一个可以循环执行任务的线程，在没有任务时进行等待；任务队列的作用是提供一种缓冲机制，将没有处理的任务放在任务队列中；任务接口是每个任务必须实现的接口，主要用来规定任务的入口、任务执行完后的收尾工作、任务的执行状态等，工作线程通过该接口调度任务的执行。下面的代码实现了创建一个线程池，以及从线程池中取出线程的操作：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <BR><BR>public class ThreadPool<BR>{ <BR>private Stack threadpool = new Stack();<BR>private int poolSize;<BR>private int currSize=0;<BR>public void setSize(int n)<BR>{ <BR>poolSize = n;<BR>}<BR>public void run()<BR>{<BR>for(int i=0;i&lt;poolSize;i++)<BR>{ <BR>WorkThread workthread=new WorkThread();<BR>threadpool.push(workthread);<BR>currSize++;<BR>}<BR>}<BR>public synchronized WorkThread getworker( )<BR>{<BR>if (threadpool.empty())<BR>system.out.println(“stack is empty”);<BR>else<BR>try{ return threadpool.pop();<BR>} catch (EmptyStackException e){}<BR>}<BR>}<BR><BR><BR><BR><BR></SPAN><B><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">线程池适合应用的场合</SPAN></B><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"><BR><BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">当一个</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">Web</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; LETTER-SPACING: 0.35pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">服务器接受到大量短小线程的请求时，使用线程池技术是非常合适的，它可以大大减少线程的创建和销毁次数，提高服务器的工作效率。但如果线程要求的运行时间比较长，此时线程的运行时间比创建时间要长得多，单靠减少创建时间对系统效率的提高不明显，此时就不适合应用线程池技术，需要借助其它的技术来提高服务器的服务效率。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #284b78; LINE-HEIGHT: 150%; FONT-FAMILY: Verdana; LETTER-SPACING: 0.35pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体"> <o:p></o:p></SPAN></P><img src ="http://www.blogjava.net/coolbar/aggbug/9201.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/coolbar/" target="_blank">专注java分布式</a> 2005-08-04 14:19 <a href="http://www.blogjava.net/coolbar/archive/2005/08/04/9201.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在JBuilder中使用Jacorb的一些设置 </title><link>http://www.blogjava.net/coolbar/archive/2005/08/03/9128.html</link><dc:creator>专注java分布式</dc:creator><author>专注java分布式</author><pubDate>Wed, 03 Aug 2005 06:42:00 GMT</pubDate><guid>http://www.blogjava.net/coolbar/archive/2005/08/03/9128.html</guid><wfw:comment>http://www.blogjava.net/coolbar/comments/9128.html</wfw:comment><comments>http://www.blogjava.net/coolbar/archive/2005/08/03/9128.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/coolbar/comments/commentRss/9128.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/coolbar/services/trackbacks/9128.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="BACKGROUND: white; MARGIN: 8.8pt 0cm 8.8pt 18pt; TEXT-INDENT: -18pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt" align=left><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana; mso-font-kerning: 0pt"><SPAN style="mso-list: Ignore">    1.</SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">安装</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">JacORB<BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">解压缩，会生成一个新的目录</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">JacORB</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">。然后将</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">JacORB/lib/jacorb.jar</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">加</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">(classpath) </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中。如果你想重新编译</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">JacORB</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">，也不要忘记将</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">JacORB/class </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">加入类路径，并且将</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">JacORB/bin</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">加到</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">Path</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">，在</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">JacORB/bin</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">下有一些实用程序。</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"><BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">重新编译</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">JacORB(</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">以及</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">JacORB</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">附带的例子</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">)</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">需要安装</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">Ant</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">，</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">Ant</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">是基于</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">XML</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的制作管理工具。要重新编译</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">JacORB</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">，只需在安装目录</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">(JacORB) </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中输入</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">ant</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">命令即可。在执行</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"> ant </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">命令之前，可以执行</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"> ant clean </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">来清除上次编译产生的中间文件。<BR></SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">2. </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">配置</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">JacORB<BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">将</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">X:JacORBetc </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">文件夹下的</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"> jacorb_properties.template </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">文件改名为</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"> jacorb.properties </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">，然后复制到类路径中。</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"><BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">设置</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"> ORBInitRef.NameService </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">参数</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"><BR>3.JBuilder</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中的设置</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"><BR>I. </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">将</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"> JacORB/lib </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">加入类路径</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"><BR>II. Tools->Enterprise Setup->CORBA->NEW<BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">其中</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"> Path for ORB tools: <SPAN style="COLOR: blue">X:/JacORB/bin<BR></SPAN>IDL compiler command: <SPAN style="COLOR: blue">idl.bat<BR></SPAN>Command option for output directory: <SPAN style="COLOR: blue">-d</SPAN><BR>III. Project->Project Properties->Paths<BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">将</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"> JacORB/lib </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">加入</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">Required Libraries<BR>IV. Project->Project Properties->IDL<BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">其中</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"> IDL compiler: </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">选择第二步新建的</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">compiler<BR>Additional options: <A name=OLE_LINK1><SPAN style="COLOR: blue">-ami_callback</SPAN></A><BR>V. </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">在需要编译的</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">idl</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">文件上单击鼠标右键，选择</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">Properties,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">在</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">Process this IDL file </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的选项上打勾</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"><BR>VI. Rebuild Project </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">即可。</SPAN><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="BACKGROUND: white; MARGIN: 8.8pt 0cm; TEXT-ALIGN: left; mso-pagination: widow-orphan" align=left><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">注意：执行程序时必须指定</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">vm</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">参数</SPAN><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">-Djava.endorsed.dirs="E:\JacORB\lib" </SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">(</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">在</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">JBuilder</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中<FONT face=Verdana><FONT color=#000000>Project</FONT> Properties</FONT> 里的</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">Runtime Configuration</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">里设置</SPAN><SPAN lang=EN-US style="FONT-FAMILY: Verdana; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">)<o:p></o:p></SPAN></P><img src ="http://www.blogjava.net/coolbar/aggbug/9128.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/coolbar/" target="_blank">专注java分布式</a> 2005-08-03 14:42 <a href="http://www.blogjava.net/coolbar/archive/2005/08/03/9128.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>