﻿<?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-经验不在于年限，在于积累---专注互联网软件开发-随笔分类-学习心得</title><link>http://www.blogjava.net/hankchen/category/41482.html</link><description>把工作当事业做，把项目当作品做！</description><language>zh-cn</language><lastBuildDate>Sun, 08 Apr 2012 20:06:20 GMT</lastBuildDate><pubDate>Sun, 08 Apr 2012 20:06:20 GMT</pubDate><ttl>60</ttl><item><title>国外程序员推荐：每个程序员都应读的书 zz</title><link>http://www.blogjava.net/hankchen/archive/2012/04/08/373569.html</link><dc:creator>hankchen</dc:creator><author>hankchen</author><pubDate>Sun, 08 Apr 2012 01:08:00 GMT</pubDate><guid>http://www.blogjava.net/hankchen/archive/2012/04/08/373569.html</guid><wfw:comment>http://www.blogjava.net/hankchen/comments/373569.html</wfw:comment><comments>http://www.blogjava.net/hankchen/archive/2012/04/08/373569.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hankchen/comments/commentRss/373569.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hankchen/services/trackbacks/373569.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp; 编者按：2008年8月4日，StackOverflow 网友 Bert F 发帖提问：哪本最具影响力的书，是每个程序员都应该读的？ “如果能时光倒流，回到过去，作为一个开发人员，你可以告诉自己在职业生涯初期应该读一本，你会选择哪本书呢？我希望这个书单列表内容丰富，可以涵盖很多东西。” 很多程序员响应，他们在推荐时也写下自己的评语。以前就有国内网友介绍这个程序员书单，不过都是推荐数 T...&nbsp;&nbsp;<a href='http://www.blogjava.net/hankchen/archive/2012/04/08/373569.html'>阅读全文</a><img src ="http://www.blogjava.net/hankchen/aggbug/373569.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hankchen/" target="_blank">hankchen</a> 2012-04-08 09:08 <a href="http://www.blogjava.net/hankchen/archive/2012/04/08/373569.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Google Collections，很不错的东东</title><link>http://www.blogjava.net/hankchen/archive/2010/01/10/308944.html</link><dc:creator>hankchen</dc:creator><author>hankchen</author><pubDate>Sun, 10 Jan 2010 12:43:00 GMT</pubDate><guid>http://www.blogjava.net/hankchen/archive/2010/01/10/308944.html</guid><wfw:comment>http://www.blogjava.net/hankchen/comments/308944.html</wfw:comment><comments>http://www.blogjava.net/hankchen/archive/2010/01/10/308944.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hankchen/comments/commentRss/308944.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hankchen/services/trackbacks/308944.html</trackback:ping><description><![CDATA[<p><font style="background-color: #cce8cf">Google Collections是Google开源的Java集合框架，建立在JDK 1.5之上，对JDK的集合类是一个很好的补充。Google内部很多系统都使用了这个项目。<br />
提供了两类强大的集合：<br />
（1）Immutable集合<br />
（2）Multimap、Multiset等<br />
<br />
其中，Immutable集合可以方便建立不可变的数据容器。Multimap、Multiset使一些复杂的集合组合类型变得简单优雅。<br />
Multimap可以提供柱状图类型的数据存储。<br />
</font></p>
<p><font style="background-color: #cce8cf"><a href="http://code.google.com/p/google-collections/">项目地址：http://code.google.com/p/google-collections/</a></font> <br />
<br />
本博相关文章：<br />
<font style="background-color: #cce8cf"><a id="viewpost1_TitleUrl" href="http://www.blogjava.net/hankchen/archive/2010/01/13/309257.html">Google Collections之Multimap、Multiset</a>&nbsp;<br />
<a href="http://www.blogjava.net/hankchen/archive/2010/01/13/309257.html">http://www.blogjava.net/hankchen/archive/2010/01/13/309257.html</a><br />
</font><a id="viewpost1_TitleUrl" href="http://www.blogjava.net/hankchen/archive/2010/01/13/309255.html">Google Collections之Immutable类</a>&nbsp; <br />
<font style="background-color: #cce8cf"><a href="http://www.blogjava.net/hankchen/archive/2010/01/13/309255.html">http://www.blogjava.net/hankchen/archive/2010/01/13/309255.html</a></font><br />
<br />
<span style="font-size: 12pt; color: black; font-family: 'Times New Roman', 'serif'"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体"><span style="font-size: 12pt; font-family: 宋体"><strong>（友情提示：本博文章欢迎转载，但请注明出处：hankchen，</strong><a title="http://www.blogjava.net/hankchen" href="http://www.blogjava.net/hankchen"><strong>http://www.blogjava.net/hankchen</strong></a><strong>）</strong></span></span></span></p>
<img src ="http://www.blogjava.net/hankchen/aggbug/308944.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hankchen/" target="_blank">hankchen</a> 2010-01-10 20:43 <a href="http://www.blogjava.net/hankchen/archive/2010/01/10/308944.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Eclipse/MyEclipse最常用的快捷键 zz</title><link>http://www.blogjava.net/hankchen/archive/2010/01/10/308938.html</link><dc:creator>hankchen</dc:creator><author>hankchen</author><pubDate>Sun, 10 Jan 2010 12:03:00 GMT</pubDate><guid>http://www.blogjava.net/hankchen/archive/2010/01/10/308938.html</guid><wfw:comment>http://www.blogjava.net/hankchen/comments/308938.html</wfw:comment><comments>http://www.blogjava.net/hankchen/archive/2010/01/10/308938.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hankchen/comments/commentRss/308938.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hankchen/services/trackbacks/308938.html</trackback:ping><description><![CDATA[<h1>F<span style="font-family: 宋体">键类</span></h1>
<p>F2<span style="font-family: 宋体">显示详细信息</span></p>
<p>F3<span style="font-family: 宋体">跳到声明或定义的地方</span></p>
<h1>Ctrl + <span style="font-family: 宋体">键类</span></h1>
<p>Ctrl+1 <span style="font-family: 宋体">快速修复</span>(<span style="font-family: 宋体">最经典的快捷键</span>,<span style="font-family: 宋体">就不用多说了</span>)</p>
<p>Ctrl+D<span style="font-family: 宋体">删除当前行</span></p>
<p>Ctrl+E <span style="font-family: 宋体">快速显示当前</span>Editer<span style="font-family: 宋体">的下拉列表</span>(<span style="font-family: 宋体">如果当前页面没有显示的用黑体表示</span>)</p>
<p>Ctrl+T <span style="font-family: 宋体">快速显示当前类的继承结构</span></p>
<p>Ctrl+O <span style="font-family: 宋体">快速显示</span> OutLine</p>
<p>Ctrl+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; F <span style="font-family: 宋体">查找</span>/<span style="font-family: 宋体">替换</span></p>
<p>Ctrl+ / <span style="font-family: 宋体">在代码窗口中是这种注释（推荐使用</span>Ctrl +Shift + C<span style="font-family: 宋体">注释）</span></p>
<p>Ctrl+Q <span style="font-family: 宋体">定位到最后编辑的地方</span></p>
<p>Ctrl+L <span style="font-family: 宋体">定位在某行</span></p>
<p>Ctrl+W <span style="font-family: 宋体">关闭当前</span>Editer</p>
<p>Ctrl+K <span style="font-family: 宋体">参照选中的</span>Word<span style="font-family: 宋体">快速定位到下一个</span></p>
<p>Ctrl+-(<span style="font-family: 宋体">小键盘</span>) <span style="font-family: 宋体">折叠当前类中的所有代码</span></p>
<p>Ctrl++(<span style="font-family: 宋体">小键盘</span>) <span style="font-family: 宋体">展开当前类中的所有代码</span></p>
<p>Ctrl+J <span style="font-family: 宋体">正向增量查找</span>(<span style="font-family: 宋体">查看</span>State Bar)(Ctrl+Shift+J <span style="font-family: 宋体">反向增量查找</span>)</p>
<h1>Shift +<span style="font-family: 宋体">键类</span></h1>
<p>Shift+Enter <span style="font-family: 宋体">在当前行的下一行插入空行</span>(<span style="font-family: 宋体">这时鼠标可以在当前行的任一位置</span>,<span style="font-family: 宋体">不一定是最后</span>)</p>
<h1>Alt+ <span style="font-family: 宋体">键类</span></h1>
<p>Alt+<span style="font-family: 宋体">&#8595;</span> <span style="font-family: 宋体">当前行和下面一行交互位置</span>(<span style="font-family: 宋体">特别实用</span>,<span style="font-family: 宋体">可以省去先剪切</span>,<span style="font-family: 宋体">再粘贴了</span>)</p>
<p>Alt+<span style="font-family: 宋体">&#8593;</span> <span style="font-family: 宋体">当前行和上面一行交互位置</span>(<span style="font-family: 宋体">同上</span>)</p>
<p>Alt+<span style="font-family: 宋体">&#8592;</span> <span style="font-family: 宋体">前一个编辑的页面</span></p>
<p>Alt+<span style="font-family: 宋体">&#8594;</span> <span style="font-family: 宋体">下一个编辑的页面</span>(<span style="font-family: 宋体">当然是针对上面那条来说了</span>)</p>
<p>Alt+Enter <span style="font-family: 宋体">显示当前选择资源</span>(<span style="font-family: 宋体">工程</span>/<span style="font-family: 宋体">文件</span>/<span style="font-family: 宋体">文件</span>)<span style="font-family: 宋体">的属性</span></p>
<h1>Ctrl + Shift + <span style="font-family: 宋体">键类</span></h1>
<p>Ctrl +Shift+C<span style="font-family: 宋体">在代码窗口中是这种注释（再次按下，取消注释）</span></p>
<p>Ctrl+Shift+F <span style="font-family: 宋体">格式化当前代码</span></p>
<p>Ctrl+Shift+O<span style="font-family: 宋体">作用是缺少的</span>Import<span style="font-family: 宋体">语句被加入，多余的</span>Import<span style="font-family: 宋体">语句被删除</span></p>
<p>Ctrl+Shift+M(<span style="font-family: 宋体">先把光标放在需导入包的类名上</span>) <span style="font-family: 宋体">作用是加</span>Import<span style="font-family: 宋体">语句</span></p>
<p>Ctrl +Shift+T<span style="font-family: 宋体">打开类型（查找文件很方便）</span></p>
<p>Ctrl+Shift+W<span style="font-family: 宋体">关闭当前所有打开文件</span></p>
<p>Ctrl+Shift+S <span style="font-family: 宋体">保存所有未保存的文件</span></p>
<p>Ctrl+Shift+E <span style="font-family: 宋体">显示管理当前打开的所有的</span>View<span style="font-family: 宋体">的管理器</span>(<span style="font-family: 宋体">可以选择关闭</span>,<span style="font-family: 宋体">激活等操作</span>)</p>
<p>Ctrl+Shift+X <span style="font-family: 宋体">把当前选中的文本全部变为大写</span></p>
<p>Ctrl+Shift+Y <span style="font-family: 宋体">把当前选中的文本全部变为小写</span></p>
<p>Ctrl+Shift+J <span style="font-family: 宋体">反向增量查找</span>(Ctrl+J <span style="font-family: 宋体">正向增量查找</span>)</p>
<h1>Ctrl+Alt + <span style="font-family: 宋体">键类</span></h1>
<p>Ctrl+Alt+<span style="font-family: 宋体">&#8595;</span> <span style="font-family: 宋体">复制当前行到下一行</span>(<span style="font-family: 宋体">复制增加</span>)</p>
<p>Ctrl+Alt+<span style="font-family: 宋体">&#8593;</span> <span style="font-family: 宋体">复制当前行到上一行</span>(<span style="font-family: 宋体">复制增加</span>)</p>
<h1>Alt+Shift + <span style="font-family: 宋体">键类</span></h1>
<p><span style="font-family: 宋体">下面的快捷键是重构里面常用的</span> (<span style="font-family: 宋体">注</span>:<span style="font-family: 宋体">一般重构的快捷键都是</span>Alt+Shift + <span style="font-family: 宋体">键类</span><span style="font-family: 宋体">的</span>)</p>
<p>Alt+Shift+R <span style="font-family: 宋体">重命名</span>(<span style="font-family: 宋体">当然，</span>F2<span style="font-family: 宋体">也能有一样的作用</span>)</p>
<p>Alt+Shift+M<span style="font-family: 宋体">抽取方法</span> (<span style="font-family: 宋体">这是重构里面最常用的方法之一了</span>,<span style="font-family: 宋体">尤其是对一大堆泥团代码有用</span>)</p>
<p>Alt+Shift+L <span style="font-family: 宋体">抽取本地变量</span></p>
<p>Alt+Shift+C <span style="font-family: 宋体">修改方法结构</span>(<span style="font-family: 宋体">比较实用</span>,<span style="font-family: 宋体">有多个类中调用了这个方法</span>,<span style="font-family: 宋体">修改一次搞定</span>)</p>
<p>Alt+Shift+F <span style="font-family: 宋体">把</span>Class<span style="font-family: 宋体">中的</span>local<span style="font-family: 宋体">变量变为</span>field<span style="font-family: 宋体">变量</span></p>
<p>Alt+Shift+I <span style="font-family: 宋体">分离本地变量（与抽取本地变量相反）</span></p>
<p>Alt+Shift+Z <span style="font-family: 宋体">重构的后悔药</span>(Undo)</p>
<h1><span style="font-family: 宋体">最最常用</span></h1>
<p>F2<span style="font-family: 宋体">显示详细信息</span></p>
<p>F3<span style="font-family: 宋体">跳到声明或定义的地方</span></p>
<p>Ctrl+1 <span style="font-family: 宋体">快速修复</span>(<span style="font-family: 宋体">最经典的快捷键</span>,<span style="font-family: 宋体">就不用多说了</span>)</p>
<p>Ctrl+D<span style="font-family: 宋体">删除当前行</span></p>
<p>Ctrl +Shift+C<span style="font-family: 宋体">在代码窗口中是这种注释（再次按下，取消注释）</span></p>
<p>Ctrl+Shift+F <span style="font-family: 宋体">格式化当前代码</span></p>
<p>Ctrl+Shift+O<span style="font-family: 宋体">作用是缺少的</span>Import<span style="font-family: 宋体">语句被加入，多余的</span>Import<span style="font-family: 宋体">语句被删除</span></p>
<p>Ctrl+E <span style="font-family: 宋体">快速显示当前</span>Editer<span style="font-family: 宋体">的下拉列表</span>(<span style="font-family: 宋体">如果当前页面没有显示的用黑体表示</span>)</p>
<p>Ctrl+T <span style="font-family: 宋体">快速显示当前类的继承结构</span></p>
<p>Ctrl+O <span style="font-family: 宋体">快速显示</span> OutLine</p>
<p>Ctrl+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; F <span style="font-family: 宋体">查找</span>/<span style="font-family: 宋体">替换</span></p>
<p>Ctrl +Shift+T(<span style="font-family: 宋体">查找文件</span>)</p>
<p>Alt+Shift+R <span style="font-family: 宋体">重命名</span>(<span style="font-family: 宋体">当然，</span>F2<span style="font-family: 宋体">也能有一样的作用</span>)</p>
<p>Alt+Shift+M<span style="font-family: 宋体">抽取方法</span> (<span style="font-family: 宋体">这是重构里面最常用的方法之一了</span>,<span style="font-family: 宋体">尤其是对一大堆泥团代码有用</span>)</p>
<p>Alt+Shift+L <span style="font-family: 宋体">抽取本地变量</span></p>
<h1><span style="font-family: 宋体"><br />
来自：<font style="background-color: #cce8cf">http://www.blogjava.net/lishunli/archive/2010/01/07/308612.html</font></span></h1>
<img src ="http://www.blogjava.net/hankchen/aggbug/308938.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hankchen/" target="_blank">hankchen</a> 2010-01-10 20:03 <a href="http://www.blogjava.net/hankchen/archive/2010/01/10/308938.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>优化MyEclipse总结 zz</title><link>http://www.blogjava.net/hankchen/archive/2010/01/08/308785.html</link><dc:creator>hankchen</dc:creator><author>hankchen</author><pubDate>Fri, 08 Jan 2010 14:38:00 GMT</pubDate><guid>http://www.blogjava.net/hankchen/archive/2010/01/08/308785.html</guid><wfw:comment>http://www.blogjava.net/hankchen/comments/308785.html</wfw:comment><comments>http://www.blogjava.net/hankchen/archive/2010/01/08/308785.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hankchen/comments/commentRss/308785.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hankchen/services/trackbacks/308785.html</trackback:ping><description><![CDATA[1.自动代码提示：<br />
<span style="color: #0000ff">windows&#8211;&gt;perferences&#8211;&gt;Java-&gt;Editor-&gt;Content Assist，在Auto-Activation下的for Java后面输入&#8220;.abcdefghijklmnopqrstuvwxyz&#8221;，应用、</span><span style="color: #0000ff">保存。</span><span style="color: #0000ff"><br />
<br />
2、取消MyEclipse在启动时自动验证项目配置文件 <br />
默认情况下MyEclipse在启动的时候会自动验证每个项目的配置文件，这是一个非常耗时的过程。<br />
windows&#8211;&gt;perferences&#8211;&gt;myeclipse&#8211;&gt;validation <br />
把manual 下面的全部勾上，build下只留classpath dependency Validator这一项。 <br />
<br />
手工验证方法：在要验证的文件上，单击鼠标右键&#8211;&gt;myeclipse&#8211;&gt;run validation <br />
<br />
3、去掉拼写检查（如果你觉的有用可以不去） <br />
<br />
拼写检查会给我们带来不少的麻烦，我们的方法命名都会是单词的缩写，他也会提示有错，所以最好去掉，没有多大的用处： <br />
windows&#8211;&gt;perferences&#8211;&gt;general&#8211;&gt;validation-&gt;editors-&gt;Text Editors-&gt;spelling <br />
<br />
myeclipse 打开 jsp 的默认编辑器不好，会同时打开预览 <br />
windows&#8211;&gt;perferences&#8211;&gt;general&#8211;&gt;editors-&gt;file associations, <br />
<br />
把默认改成 MyEclipse JSP Editor（） <br />
原默认的jsp编辑器是 MyEclipse Visual JSP Designer，顾名思义，此编译器是jsp可视化编辑器，对于初学者有很多的帮助， <br />
但修改此项的默认编辑器其实可以提高启动速度） <br />
<br />
4、加大JVM的非堆内存 <br />
<br />
打开 myeclipse.ini <br />
-startup <br />
../Common\plugins\org.eclipse.equinox.launcher_1.0.101.R34x_v20081125.jar <br />
--launcher.library <br />
../Common\plugins\org.eclipse.equinox.launcher.win32.win32.x86_1.0.101.R34x_v20080731 <br />
-clean <br />
-configuration <br />
configuration <br />
-vm <br />
C:\Users\lenovo\AppData\Local\Genuitec\Common\binary\com.sun.java.jdk.win32.x86_1.6.0.013\jre\bin\client\jvm.dll <br />
-vmargs <br />
-Xmx384m <br />
-XX:MaxPermSize=384m <br />
-XX:ReservedCodeCacheSize=96m <br />
<br />
以上是我的myeclipse.ini，需要修改是-Xmx，-XX:MaxPermSize，-XX:ReservedCodeCacheSize， <br />
将这三项的值调大，但并不是越大越好，曾经在相同的条件下做过测试（内存2GB），-Xmx，-XX:MaxPermSize的值为384m时比512m时要快（视具体的计算机而定）， <br />
-Xmx，-XX:MaxPermSize的值设为同样大小且两者之和不能超出你的计算机本身的内存大小。<br />
<br />
5. 去掉启动时的自动更新<br />
（1）Window --&gt; Preferences --&gt; General --&gt; Startup and Shutdown --&gt;找到"Automatic Updates Scheduler " 项去掉前面的勾。<br />
（2）Window --&gt; Preferences --&gt; Myeclipse Enterprise Workbench --&gt; Maven4Myeclipse --&gt; Maven --&gt; "Download repository index updates on startup" 去掉前面的勾。<br />
&nbsp;<br />
6. 在编译时过滤掉SVN文件<br />
Window--&gt;Preferences--&gt;Java--&gt;Compiler--&gt;Building，点击Output Folder，在Filtered Resources输入框填入：*.svn<br />
<br />
<br />
<br />
来自：<font style="background-color: #cce8cf">http://www.javaeye.com/topic/464943?page=1</font><br />
</span>
<img src ="http://www.blogjava.net/hankchen/aggbug/308785.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hankchen/" target="_blank">hankchen</a> 2010-01-08 22:38 <a href="http://www.blogjava.net/hankchen/archive/2010/01/08/308785.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java 5.0 高性能程序开发总结（不断补充）</title><link>http://www.blogjava.net/hankchen/archive/2009/12/30/307796.html</link><dc:creator>hankchen</dc:creator><author>hankchen</author><pubDate>Wed, 30 Dec 2009 08:54:00 GMT</pubDate><guid>http://www.blogjava.net/hankchen/archive/2009/12/30/307796.html</guid><wfw:comment>http://www.blogjava.net/hankchen/comments/307796.html</wfw:comment><comments>http://www.blogjava.net/hankchen/archive/2009/12/30/307796.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/hankchen/comments/commentRss/307796.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hankchen/services/trackbacks/307796.html</trackback:ping><description><![CDATA[<strong><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体"><span style="font-size: 12pt; font-family: 宋体">（友情提示：本博文章欢迎转载，但请注明出处：陈新汉，<a title="http://www.blogjava.net/hankchen" href="http://www.blogjava.net/hankchen">http://www.blogjava.net/hankchen</a>）</span><br />
一、并发集合类的选择</span></strong>
<p style="line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;同步的集合类</span><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Hashtable</span></code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">和</span><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Vector</span></code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">，以及同步的包装器类</span><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Collections.synchronizedMap</span></code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">和</span><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Collections.synchronizedList</span></code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">，为</span><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Map</span></code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">和</span><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">List</span></code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">提供了基本的有条件的线程安全的实现。然而，某些因素使得它们并不适用于具有高度并发性的应用程序中</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">――</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">它们的集合范围的单锁特性对于可伸缩性来说是一个障碍，而且，很多时候还必须在一段较长的时间内锁定一个集合，以防止出现</span><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">ConcurrentModificationException</span></code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">s</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">异常。</span></p>
<p style="text-indent: 21pt; line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">ConcurrentHashMap</span></code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">和</span><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">CopyOnWriteArrayList</span></code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">实现提供了更高的并发性，同时还保住了线程安全性，只不过在对其调用者的承诺上打了点折扣。</span><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">ConcurrentHashMap</span></code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">和</span><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">CopyOnWriteArrayList</span></code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">并不是在您使用</span><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">HashMap</span></code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">或</span><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">ArrayList</span></code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">的任何地方都一定有用，但是它们是设计用来优化某些特定的公用解决方案的。许多并发应用程序将从对它们的使用中获得好处。</span></p>
<p style="line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">总结：在多线程并发情况下，为了避免</span><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">ConcurrentModificationException</span></code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">s</span><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">异常，建议使用</span><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">ConcurrentHashMap</span></code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">和</span><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">CopyOnWriteArrayList</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">。<br />
</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code>还有下面的几个可以考虑：ConcurrentLinkedQueue、CopyOnWriteArraySet、LinkedBlockingQueue、ArrayBlockingQueue<br />
&nbsp;</code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><strong><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">二、高效的乘除运算</span></strong></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">服务器计算时，对于乘除运算，采用下面的方式：</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; line-height: 150%; font-family: 'Times New Roman','serif'">A*2=a&lt;&lt;1</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; line-height: 150%; font-family: 'Times New Roman','serif'">A/2=a&gt;&gt;1</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">这样可以提高运算效率。</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code>&nbsp;</code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><strong><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">三、原子自增器</span></strong></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">多线程环境下，</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'"> AtomicInteger </span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">可用在应用程序中（如以原子方式增加的计数器），并且不能用于替换</span></code><a lang="" title="java.lang 中的类" href="mk:@MSITStore:F:"  Integer.html? java Java%20书籍?JDK_API_1_6_中文.CHM::><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'; text-decoration: none; text-underline: none">Integer</code></a></span><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">。但是，此类确实扩展了</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'"> Number</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">，允许那些处理基于数字类的工具和实用工具进行统一访问。</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><span style="font-family: 宋体">例如：</span></p>
<p style="text-align: left" align="left"><span style="font-size: 10pt; color: #3f5fbf; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;private AtomicInteger bomdIdCreator = new AtomicInteger(); //</span><span style="font-size: 10pt; color: #3f5fbf; font-family: 宋体">自增序列号</span></p>
<p style="text-align: left" align="left"><span style="font-size: 10pt; color: #3f5fbf; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp; /**</span></p>
<p style="text-align: left" align="left"><span style="font-size: 10pt; color: black; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; color: #3f5fbf; font-family: 'Courier New'">*</span><span style="font-size: 10pt; color: #3f5fbf; font-family: 宋体">得到新的炸弹</span><span style="font-size: 10pt; color: #3f5fbf; font-family: 'Courier New'">ID</span><span style="font-size: 10pt; color: #3f5fbf; font-family: 宋体">，保持自增</span></p>
<p style="text-align: left" align="left"><span style="font-size: 10pt; color: black; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; color: #3f5fbf; font-family: 'Courier New'">*</span><strong><span style="font-size: 10pt; color: #7f9fbf; font-family: 'Courier New'">@return</span></strong></p>
<p style="text-align: left" align="left"><span style="font-size: 10pt; color: black; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; color: #3f5fbf; font-family: 'Courier New'">*/</span></p>
<p style="text-align: left" align="left"><span style="font-size: 10pt; color: black; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">public </span></strong><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">int</span></strong><span style="font-size: 10pt; color: black; font-family: 'Courier New'"> getNewBombID(){</span></p>
<p style="text-align: left" align="left"><span style="font-size: 10pt; color: black; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">return </span></strong><span style="font-size: 10pt; color: #0000c0; font-family: 'Courier New'">bomdIdCreator</span><span style="font-size: 10pt; color: black; font-family: 'Courier New'">.addAndGet(1);</span></p>
<p style="text-indent: 19.5pt; line-height: 150%; text-align: left" align="left"><span style="font-size: 10pt; color: black; line-height: 150%; font-family: 'Courier New'">}</span></p>
<p style="line-height: 150%; text-align: left" align="left"><code><strong><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">四、多线程锁机制实现</span></strong></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">多线程环境下，为了避免资源竞争，引入了锁机制。一般实现锁机制有下面几种方法：</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">1. </span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">同步方法、同步块：</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">synchronized</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">2. </span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">监视器方法：（</span></code><a lang="" href="mk:@MSITStore:F:"  java Java%20书籍?JDK_API_1_6_中文.CHM:: Object.html#wait()?><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'; text-decoration: none; text-underline: none">wait</code></a></span><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">、</span></code><a lang="" href="mk:@MSITStore:F:"  java Java%20书籍?JDK_API_1_6_中文.CHM:: Object.html#notify()?><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'; text-decoration: none; text-underline: none">notify</code></a></span><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">和</span></code><a lang="" href="mk:@MSITStore:F:"  java Java%20书籍?JDK_API_1_6_中文.CHM:: Object.html#notifyAll()?><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'; text-decoration: none; text-underline: none">notifyAll</code></a></span><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">）</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">3.&nbsp;ReentrantLock&nbsp; <br />
</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体"><br />
注意：ReentrantLock是一个可重入的互斥锁</span></code><a title="java.util.concurrent.locks 中的接口" href="mk:@MSITStore:F:"  java Java%20书籍?JDK_API_1_6_中文.CHM:: Lock.html? locks concurrent util><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'; text-decoration: none; text-underline: none">Lock</code></a></span><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">，它具有与使用</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'"> synchronized </span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">方法和语句所访问的隐式监视器锁相同的一些基本行为和语义，但功能更强大。</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">例如：建议总是立即实践，使用</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'"> lock </span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">块来调用</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'"> try</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">，在之前</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">/</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">之后的构造中，最典型的代码如下：</span></code></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;class X {</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp; private final ReentrantLock lock = new ReentrantLock();</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp; // ...</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp; public void m() { </span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp; lock.lock();&nbsp;// block until condition holds</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp; &nbsp;&nbsp;try {</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // ... method body</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp; } finally {</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lock.unlock()</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp; }</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp; }</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;}</span></strong></p>
<p style="text-align: left" align="left"><strong>&nbsp;</strong></p>
<p style="line-height: 150%; text-align: left" align="left"><code><strong><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">五、线程池的实现方式</span></strong></code></p>
<p style="text-indent: 21pt; line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; line-height: 150%; font-family: 'Times New Roman','serif'">Doug Lea </span></code><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">编写了一个优秀的并发实用程序开放源码库</span></code><code><span style="font-size: 12pt; line-height: 150%; font-family: 'Times New Roman','serif'"> <span style="color: black">util.concurrent</span></span></code><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">，它包括互斥、信号量、诸如在并发访问下执行得很好的队列和散列表之类集合类以及几个工作队列实现。该包中的</span></code><code><span style="font-size: 12pt; line-height: 150%; font-family: 'Times New Roman','serif'"> <span style="color: red">ThreadPoolExecutor</span></span></code><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">类是一种有效的、广泛使用的以工作队列为基础的<span style="color: red">线程池</span>的正确实现。您无须尝试编写您自己的线程池，这样做容易出错，相反您可以考虑使用</span></code><code><span style="font-size: 12pt; line-height: 150%; font-family: 'Times New Roman','serif'"> <span style="color: black">util.concurrent</span></span></code><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">中的一些实用程序。</span></code></p>
<p style="text-indent: 21pt; line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">线程池可以解决两个不同问题：由于减少了每个任务调用的开销，它们通常可以在执行大量异步任务时提供增强的性能，并且还可以提供绑定和管理资源（包括执行集合任务时使用的线程）的方法。</span></code></p>
<p style="text-indent: 21pt; line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">强烈建议程序员使用较为方便的</span></code><a title="java.util.concurrent 中的类" href="mk:@MSITStore:F:"  java concurrent util Executors.html? api Java%20书籍?JDK1.5%20中文版文档.CHM::><code><span style="font-size: 12pt; color: windowtext; line-height: 150%; font-family: 'Times New Roman','serif'; text-decoration: none; text-underline: none">Executors</code></a></span><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">工厂方法</span></code><a href="mk:@MSITStore:F:"  java concurrent util api Java%20书籍?JDK1.5%20中文版文档.CHM:: Executors.html#newCachedThreadPool()?><code><span style="font-size: 12pt; color: windowtext; line-height: 150%; font-family: 'Times New Roman','serif'; text-decoration: none; text-underline: none">Executors.newCachedThreadPool()</code></a></span><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">（无界线程池，可以进行自动线程回收）、</span></code><a href="mk:@MSITStore:F:"  java concurrent util api Java%20书籍?JDK1.5%20中文版文档.CHM:: Executors.html#newFixedThreadPool(int)?><code><span style="font-size: 12pt; color: windowtext; line-height: 150%; font-family: 'Times New Roman','serif'; text-decoration: none; text-underline: none">Executors.newFixedThreadPool(int)</code></a></span><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">（固定大小线程池）和</span></code><a href="mk:@MSITStore:F:"  java concurrent util api Java%20书籍?JDK1.5%20中文版文档.CHM:: Executors.html#newSingleThreadExecutor()?><code><span style="font-size: 12pt; color: windowtext; line-height: 150%; font-family: 'Times New Roman','serif'; text-decoration: none; text-underline: none">Executors.newSingleThreadExecutor()</code></a></span><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">（单个后台线程），它们均为大多数使用场景预定义了设置。</span></code></p>
<p style="text-indent: 21pt; line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">例如：</span></code></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">public class ThreadPoolExecutorTest {</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp; final static ExecutorService threadPool=Executors.newCachedThreadPool(); //</span></strong><strong><span style="font-size: 10pt; color: #7f0055; font-family: 宋体">简单线程池实现</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp; /**</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp; &nbsp;* @param args</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp; &nbsp;*/</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp; public static void main(String[] args) {</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int i=0;i&lt;10;i++){</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; threadPool.execute(new Runnable(){</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void run() {</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("aaa"+this.getClass().getName());</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //do other things </span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp; }</span></strong></p>
<p style="text-align: left" align="left"><strong><span style="font-size: 10pt; color: #7f0055; font-family: 'Courier New'">}</span></strong></p>
<p style="text-align: left" align="left"><code><strong>&nbsp;</strong></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><strong><span style="font-size: 12pt; line-height: 150%; font-family: 宋体">六、实现定时任务的几种方式比较</span></strong></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">1. </span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">使用原始的</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">Timer</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">类</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">2. &nbsp;ScheduledThreadPoolExecutor </span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">（</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">JDK 1.5</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">新增）</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">3. &nbsp;Quatz</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">开源项目</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">从</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Java 5.0</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">开始，</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">java.util.concurrent</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">包中增加了一个</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">ScheduledThreadPoolExecutor</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">类，用来实现定时任务和线程池的管理，比起</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Timer</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">简陋的实现是要强大得多。利用</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">ScheduledThreadPoolExecutor</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">的</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">scheduleAtFixedRate()</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">和</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">scheduleWithFixedDelay()</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">两个方法就可以实现任务调度的基本功能，从前用</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Timer</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">实现的功能应该要迁移到</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">scheduleWithFixedDelay()</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">上了。</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><strong><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">注意：</span></strong></code><code><strong><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">ScheduledThreadPoolExecutor</span></strong></code><code><strong><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">是实现</span></strong></code><code><strong><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">ScheduledExecutorService</span></strong></code><code><strong><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">接口的具体类。<br />
</span></strong></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><font style="background-color: #cce8cf">1）public static final ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(2);<br />
2）public static final ScheduledThreadPoolExecutor scheduledExecutor=new ScheduledThreadPoolExecutor(2);<br />
这两种方式是一样的，都是得到一个可调度的线程池。</font><br />
&nbsp;</code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">ScheduledThreadPoolExecutor</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">与</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 'Times New Roman','serif'">Timer</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">的区别：</span></code></p>
<p style="margin-left: 18pt; text-indent: -18pt; line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">1.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Timer</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">的主要方法有：</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">// </span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">安排在指定的时间执行</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">void schedule(TimerTask task, Date time)</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">// </span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">安排在指定的时间开始以</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">重复的延时</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">执行</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">void schedule(TimerTask task, Date firstTime, long period)</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">// </span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">安排在指定的延迟后执行</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">void schedule(TimerTask task, long delay)</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">// </span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">安排在指定的延迟后开始以重复的延时执行</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">void schedule(TimerTask task, long delay, long period)</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">// </span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">安排在指定的时间开始以</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">重复的速率</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">执行</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">void scheduleAtFixedRate(TimerTask task, Date firstTime, long period)</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">// </span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">安排在指定的延迟后开始以重复的速率执行</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">void scheduleAtFixedRate(TimerTask task, long delay, long period)</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code>&nbsp;</code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">注：</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">重复的延时</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">和</span></code><code><span style="font-size: 12pt; color: red; line-height: 150%; font-family: 宋体">重复的速率</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">的区别在于，前者是在前一个任务的执行结束后间隔</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">period</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">时间再开始下一次执行；而</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">scheduleAtFixedRate</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">则是会尽量按照任务的初始时间来按照间隔</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">period</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">时间执行。如果一次任务执行由于某些原因被延迟了，用</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">schedule()</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">调度的后续任务同样也会被延迟，而用</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">scheduleAtFixedRate()</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">则会快速的开始两次或者多次执行，是后续任务的执行时间能够赶上来。</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code>&nbsp;</code></p>
<p style="margin-left: 18pt; text-indent: -18pt; line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">2.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">ScheduledThreadPoolExecutor</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">的主要方法：</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">// </span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">在指定的延迟后执行</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">&lt;V&gt;ScheduledFuture&lt;V&gt; schedule(Callable&lt;V&gt; callable, long delay, TimeUnit unit)</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">// </span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">在指定的延迟后执行</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">ScheduledFuture&lt;?&gt; schedule(Runnable command, long delay, TimeUnit unit)</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">// </span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">在指定的延迟后以固定速率执行</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">(</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">类似</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Timer.scheduleAtFixedRate())</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">ScheduledFuture&lt;?&gt; scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">// </span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">在指定的延迟后以固定间隔执行</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">(</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">类似</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Timer.schedule())</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">ScheduledFuture&lt;?&gt; scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code>&nbsp;</code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">比较：</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">（</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">1</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">）</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Timer</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">对调度的支持是基于绝对时间的，因此任务对系统时间的改变是敏感的；而</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">ScheduledThreadPoolExecutor</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">支持相对时间。</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">（</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">2</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">）</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Timer</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">使用单线程方式来执行所有的</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">TimerTask</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">，如果某个</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">TimerTask</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">很耗时则会影响到其他</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">TimerTask</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">的执行；而</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">ScheduledThreadPoolExecutor</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">则可以构造一个固定大小的线程池来执行任务。</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">（</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">3</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">）</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Timer</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">不会捕获由</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">TimerTask</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">抛出的未检查异常，故当有异常抛出时，</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Timer</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">会终止，导致未执行完的</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">TimerTask</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">不再执行，新的</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">TimerTask</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">也不能被调度；</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">ScheduledThreadPoolExecutor</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">对这个问题进行了妥善的处理，不会影响其他任务的执行。</span></code></p>
<p style="line-height: 150%; text-align: left" align="left"><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">结论：</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Timer</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">有这么多的缺点，如果是使用</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">JDK1.5</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">以上的话，应该没什么理由要使用</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Timer</span></code><code><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">来进行调度。<br />
<span style="font-size: 12pt; font-family: 宋体">（友情提示：本博文章欢迎转载，但请注明出处：陈新汉，<a title="http://www.blogjava.net/hankchen" href="http://www.blogjava.net/hankchen">http://www.blogjava.net/hankchen</a>）<br />
</span></span></code></p>
<img src ="http://www.blogjava.net/hankchen/aggbug/307796.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hankchen/" target="_blank">hankchen</a> 2009-12-30 16:54 <a href="http://www.blogjava.net/hankchen/archive/2009/12/30/307796.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PowerDesigner使用总结</title><link>http://www.blogjava.net/hankchen/archive/2009/12/26/307372.html</link><dc:creator>hankchen</dc:creator><author>hankchen</author><pubDate>Sat, 26 Dec 2009 09:30:00 GMT</pubDate><guid>http://www.blogjava.net/hankchen/archive/2009/12/26/307372.html</guid><wfw:comment>http://www.blogjava.net/hankchen/comments/307372.html</wfw:comment><comments>http://www.blogjava.net/hankchen/archive/2009/12/26/307372.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hankchen/comments/commentRss/307372.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hankchen/services/trackbacks/307372.html</trackback:ping><description><![CDATA[<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体"><span style="font-size: 12pt; font-family: 宋体">（友情提示：本博文章欢迎转载，但请注明出处：陈新汉，<a title="http://www.blogjava.net/hankchen" href="http://www.blogjava.net/hankchen">http://www.blogjava.net/hankchen</a>）</span><br />
一、</span><a href="http://www.cnblogs.com/CowboyProgrammer/archive/2009/04/28/1445423.html"><strong><span style="font-size: 12pt; color: #075db3; font-family: 宋体; text-decoration: none; text-underline: none">使用</strong><strong><span style="font-size: 12pt; color: #075db3; font-family: 'Times New Roman','serif'; text-decoration: none; text-underline: none">PowerDesigner</span></strong><strong><span style="font-size: 12pt; color: #075db3; font-family: 宋体; text-decoration: none; text-underline: none">生成</span></strong><strong><span style="font-size: 12pt; color: #075db3; font-family: 'Times New Roman','serif'; text-decoration: none; text-underline: none">HTML</span></strong><strong><span style="font-size: 12pt; color: #075db3; font-family: 宋体; text-decoration: none; text-underline: none">功能</span></strong></a></span></p>
<p style="background: #fefef2; margin-bottom: 7.5pt; word-break: break-all; line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">使用</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">PowerDesigner</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">设计数据库关系以后，可以生成</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">HTML,</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">供团队成员进行讨论。</span></p>
<p style="background: #fefef2; margin-bottom: 7.5pt; word-break: break-all; line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Step 1</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">：创建一个</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">new Report;</span></p>
<p style="background: #fefef2; margin-bottom: 7.5pt; word-break: break-all; line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">选择【</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">file</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">】</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">---</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">【</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">new</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">】</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">---</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">【</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Multi-Model Report</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">】，然后定义</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Report Name,</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">这个主要是</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">HTML</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">的名称，选择</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Language</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">。</span></p>
<p style="background: #fefef2; margin-bottom: 7.5pt; word-break: break-all; line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Step 2: </span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">选择需要生成的</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Model;</span></p>
<p style="background: #fefef2; margin-bottom: 7.5pt; word-break: break-all; line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">在</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Model Name </span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">选择需要生成</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">HTML</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">的</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Model,</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">然后选择一种</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Report template,</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">这里建议选择【</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Stand Physical Report</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">】，然后点击【确定】。</span></p>
<p style="background: #fefef2; margin-bottom: 7.5pt; word-break: break-all; line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Step 3: </span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">生成</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">HTML</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">；</span></p>
<p style="background: #fefef2; margin-bottom: 7.5pt; word-break: break-all; line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">选择刚刚新创建的</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Report,</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">右键，【</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Generate</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">】</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">---</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">【</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">HTML</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">】，选择存放路径。然后选择【保存】，大功告成。</span></p>
<p><span style="font-size: 12pt; font-family: 宋体">二、创建索引</span></p>
<p style="margin-top: 12pt; background: white; word-break: break-all; line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">1.</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">双击</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Table</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">，弹出</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Table Properties</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">窗口：</span></p>
<p style="margin-top: 12pt; background: white; word-break: break-all; line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">2</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">．添加一个新的索引。</span></p>
<p style="margin-top: 12pt; background: white; word-break: break-all; line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">3</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">．选择</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">unique</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">，把索引设置为唯一索引。</span></p>
<p style="margin-top: 12pt; background: white; word-break: break-all; line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">4</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">．双击索引所在的行，弹出索引属性窗口（</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Index Properties</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">）。</span></p>
<p style="margin-top: 12pt; background: white; word-break: break-all; line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">5</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">．双击添加列按钮，弹出</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">Selection</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">窗口。</span></p>
<p style="margin-top: 12pt; background: white; word-break: break-all; line-height: 150%; text-align: left" align="left"><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">6</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">．选择索引包含的表的列，并单击</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 'Times New Roman','serif'">OK</span><span style="font-size: 12pt; color: black; line-height: 150%; font-family: 宋体">。</span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">三、添加表注释和列注释</span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">1.</span><span style="font-size: 12pt; font-family: 宋体">表注释：双击表，弹出</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Table Properties</span><span style="font-size: 12pt; font-family: 宋体">窗口，填写</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">comment</span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">2.</span><span style="font-size: 12pt; font-family: 宋体">列注释：双击左边的树形菜单的中的列，弹出列属性窗口，填写</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">comment</span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">四、使用</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">PowerDesigner</span><span style="font-size: 12pt; font-family: 宋体">设计建造</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">MySQL</span><span style="font-size: 12pt; font-family: 宋体">数据库</span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">（</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">1</span><span style="font-size: 12pt; font-family: 宋体">）使用</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">PowerDesigner</span><span style="font-size: 12pt; font-family: 宋体">制作建库脚本</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"><br />
1</span><span style="font-size: 12pt; font-family: 宋体">、设计</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">CDM(Conceptual Data Model)<br />
2</span><span style="font-size: 12pt; font-family: 宋体">、选择</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> Tools -&gt; Generate Physical Data Model </span><span style="font-size: 12pt; font-family: 宋体">，选择对应的</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">DBMS</span><span style="font-size: 12pt; font-family: 宋体">为</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">MySQL</span><span style="font-size: 12pt; font-family: 宋体">，生成</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">PDM<br />
3</span><span style="font-size: 12pt; font-family: 宋体">、选择</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> Database -&gt; Generate Database </span><span style="font-size: 12pt; font-family: 宋体">，在弹出的</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> Database Generation </span><span style="font-size: 12pt; font-family: 宋体">对话框中选择脚本存取路径及脚本文件名称</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"><br />
4</span><span style="font-size: 12pt; font-family: 宋体">、点击确定后生成数据库建库脚本</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">(*.sql)<br />
<br />
</span><span style="font-size: 12pt; font-family: 宋体">（</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">2</span><span style="font-size: 12pt; font-family: 宋体">）使用建库脚本建立数据库</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"><br />
1</span><span style="font-size: 12pt; font-family: 宋体">、登陆</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> mysql -u root -p<br />
2</span><span style="font-size: 12pt; font-family: 宋体">、建立空的</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">databse create databse mydbse;<br />
3</span><span style="font-size: 12pt; font-family: 宋体">、建立用户</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> grant all on mydbse.* to username@192.168.1.100 identified by 'password'</span><span style="font-size: 12pt; font-family: 宋体">；</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"><br />
4</span><span style="font-size: 12pt; font-family: 宋体">、退出</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> exit;<br />
5</span><span style="font-size: 12pt; font-family: 宋体">、在终端中输入</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> mysql -h 192.168.1.100 -u username -p &lt; Script.sql <br />
6</span><span style="font-size: 12pt; font-family: 宋体">、回车后输入密码即可</span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">五、</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"><a href="http://shshy39.javaeye.com/blog/419402"><span style="color: windowtext; text-decoration: none; text-underline: none">PowerDesigner</span><span style="color: windowtext; font-family: 宋体; text-decoration: none; text-underline: none">设计时表显示注释选项</span></a></span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">PowerDesigner</span><span style="font-size: 12pt; font-family: 宋体">设计时表显示注释选项</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">: <br />
</span><span style="font-size: 12pt; font-family: 宋体">选定编辑的表</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">,</span><span style="font-size: 12pt; font-family: 宋体">右键</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">- &gt;Properties- &gt;Columns- &gt;Customize Columns and Filter(</span><span style="font-size: 12pt; font-family: 宋体">或直接用快捷键</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Ctrl+U)- &gt;Comment(</span><span style="font-size: 12pt; font-family: 宋体">前面打勾</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">)- &gt;OK </span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">六、</span><strong><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">PowerDesigner</span></strong><strong><span style="font-size: 12pt; font-family: 宋体">使用</span></strong><strong><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">MySQL</span></strong><strong><span style="font-size: 12pt; font-family: 宋体">的</span></strong><strong><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">auto_increment</span></strong></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">打开</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">table properties</span><span style="font-size: 12pt; font-family: 宋体">窗口</span><span style="font-size: 12pt">&#8594;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> columns </span><span style="font-size: 12pt">&#8594;</span><span style="font-size: 12pt; font-family: 宋体">选中</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">id</span><span style="font-size: 12pt; font-family: 宋体">列</span><span style="font-size: 12pt">&#8594;</span><span style="font-size: 12pt; font-family: 宋体">打开</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">columns properties</span><span style="font-size: 12pt; font-family: 宋体">窗口</span><span style="font-size: 12pt">&#8594;</span><span style="font-size: 12pt; font-family: 宋体">勾选</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">identity</span><span style="font-size: 12pt; font-family: 宋体">即可。</span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">七、</span><strong><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">PowerDesigner</span></strong><strong><span style="font-size: 12pt; font-family: 宋体">去掉</span></strong><strong><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">SQL</span></strong><strong><span style="font-size: 12pt; font-family: 宋体">脚本中的双引号</span></strong></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">把</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Database </span><span style="font-size: 12pt">&#8594;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> Edit Current DBMS </span><span style="font-size: 12pt">&#8594;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> General </span><span style="font-size: 12pt">&#8594;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> Script </span><span style="font-size: 12pt">&#8594;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> Sql </span><span style="font-size: 12pt">&#8594;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> Format </span><span style="font-size: 12pt">&#8594;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> CaseSensitivityUsingQuote</span><span style="font-size: 12pt; font-family: 宋体">设置为</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">NO</span><span style="font-size: 12pt; font-family: 宋体">即可</span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">八、</span><strong><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">PowerDesigner</span></strong><strong><span style="font-size: 12pt; font-family: 宋体">中设置</span></strong><strong><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Entity</span></strong><strong><span style="font-size: 12pt; font-family: 宋体">自动调整尺寸大小</span></strong></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">在</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Entity</span><span style="font-size: 12pt; font-family: 宋体">上点击右键</span><span style="font-size: 12pt">&#8594;</span><span style="font-size: 12pt; font-family: 宋体">单击</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Format...</span><span style="font-size: 12pt; font-family: 宋体">菜单项</span><span style="font-size: 12pt">&#8594;</span><span style="font-size: 12pt; font-family: 宋体">选择</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">size</span><span style="font-size: 12pt; font-family: 宋体">标签页</span><span style="font-size: 12pt">&#8594;</span><span style="font-size: 12pt; font-family: 宋体">勾选</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Auto adjust to text</span><span style="font-size: 12pt; font-family: 宋体">即可</span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">九、</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Generate Name in Empty Comment</span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">一直用</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">PowerDesigner</span><span style="font-size: 12pt; font-family: 宋体">设计，并生成</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Oracle</span><span style="font-size: 12pt; font-family: 宋体">表结构，对于生成</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Oracle</span><span style="font-size: 12pt; font-family: 宋体">表中列的</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Comment</span><span style="font-size: 12pt; font-family: 宋体">字段却要手工补充。</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> <br />
</span><span style="font-size: 12pt; font-family: 宋体">今天同事提起</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">PowerDesigner</span><span style="font-size: 12pt; font-family: 宋体">可以自动用</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Name</span><span style="font-size: 12pt; font-family: 宋体">的说明替代</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Comment</span><span style="font-size: 12pt; font-family: 宋体">（在他的</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">PD</span><span style="font-size: 12pt; font-family: 宋体">中可以看到效果，但他也忘记如何设置）。</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> <br />
</span><span style="font-size: 12pt; font-family: 宋体">网上找下了资料</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">,</span><span style="font-size: 12pt; font-family: 宋体">很多都是说如何用</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">RUN SCRIPT</span><span style="font-size: 12pt; font-family: 宋体">的方法。最后，经过查找</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">PowerDesigner</span><span style="font-size: 12pt; font-family: 宋体">的帮忙，原来很简单。设置如下：</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> <br />
[Database]-&gt;[Database Generation]-&gt;[Options] -&gt;Generate Name in Empty Comment <br />
</span><span style="font-size: 12pt; font-family: 宋体">如果设计时没有写</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Comment</span><span style="font-size: 12pt; font-family: 宋体">，就用</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Name</span><span style="font-size: 12pt; font-family: 宋体">替代。</span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">十、修改表的字段</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Name</span><span style="font-size: 12pt; font-family: 宋体">的时候，</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Code</span><span style="font-size: 12pt; font-family: 宋体">不自动跟着变？</span>&nbsp;<span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> <br />
tools-&gt;General</span><span style="font-size: 12pt">&nbsp;&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> Options-&gt;Dialog:Operation</span><span style="font-size: 12pt">&nbsp;&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> Modes:</span><span style="font-size: 12pt">&nbsp;&nbsp;&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'"> NameToCodeMirroring(checked=false) </span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">十一、去掉默认的新建的表名和字段名加上双引号问题</span></p>
<p style="background: #fefef2; word-break: break-all; line-height: 18pt; text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">打开</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">Database -&gt; Edit Current DBMS </span><span style="font-size: 12pt; font-family: 宋体">，出现一个编辑界面，在右边的框里，找到</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">script</span><span style="font-size: 12pt; font-family: 宋体">分节点，再依次找到</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">sql -&gt; format </span><span style="font-size: 12pt; font-family: 宋体">节点，下面有一个这样的名称的属性：</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">CaseSensitivityUsingQuote</span><span style="font-size: 12pt; font-family: 宋体">，把这个属性的值设为</span><span style="font-size: 12pt">&#8220;</span><span style="font-size: 12pt; font-family: 宋体">ＮＯ</span><span style="font-size: 12pt">&#8221;</span><span style="font-size: 12pt; font-family: 宋体">，再看生成的</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif'">script</span><span style="font-size: 12pt; font-family: 宋体">，就全部双引号都去掉了。<br />
<span style="font-size: 12pt; font-family: 宋体">（友情提示：本博文章欢迎转载，但请注明出处：陈新汉，<a title="http://www.blogjava.net/hankchen" href="http://www.blogjava.net/hankchen">http://www.blogjava.net/hankchen</a>）<br />
</span><br />
</span></p>
<img src ="http://www.blogjava.net/hankchen/aggbug/307372.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hankchen/" target="_blank">hankchen</a> 2009-12-26 17:30 <a href="http://www.blogjava.net/hankchen/archive/2009/12/26/307372.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>利用Windows Live Writer离线发表blogjava日志</title><link>http://www.blogjava.net/hankchen/archive/2009/09/18/295551.html</link><dc:creator>hankchen</dc:creator><author>hankchen</author><pubDate>Fri, 18 Sep 2009 03:28:00 GMT</pubDate><guid>http://www.blogjava.net/hankchen/archive/2009/09/18/295551.html</guid><wfw:comment>http://www.blogjava.net/hankchen/comments/295551.html</wfw:comment><comments>http://www.blogjava.net/hankchen/archive/2009/09/18/295551.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hankchen/comments/commentRss/295551.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hankchen/services/trackbacks/295551.html</trackback:ping><description><![CDATA[<p><br />
首先，去官方网站<a href="http://download.live.com/writer">http://download.live.com/writer</a>下载Windows Live Writer客户端程序，然后安装。
<p>安装成功后，会在&#8220;开始--程序--Windows Live&#8221;中找到刚刚安装的Windows Live Writer程序。
<p>打开程序后，输入您的Live ID和密码进入客户端。Live ID可以是Live Spaces账号或者MSN账号等等。没有这些账户的话先去注册一个。
<p>在客户端菜单栏中，点击&#8220;日志—添加日志账户&#8221;，打开下面的窗口：
<p><a href="http://www.blogjava.net/images/blogjava_net/hankchen/WindowsLiveWriter/WindowsLiveWriterblogjava_A167/clip_image002_2.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="clip_image002" src="http://www.blogjava.net/images/blogjava_net/hankchen/WindowsLiveWriter/WindowsLiveWriterblogjava_A167/clip_image002_thumb.jpg" width="326" height="282" /></a>
<p>选择&#8220;其他日志服务&#8221;，点击&#8220;下一步&#8221;：
<p><a href="http://www.blogjava.net/images/blogjava_net/hankchen/WindowsLiveWriter/WindowsLiveWriterblogjava_A167/clip_image004_2.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="clip_image004" src="http://www.blogjava.net/images/blogjava_net/hankchen/WindowsLiveWriter/WindowsLiveWriterblogjava_A167/clip_image004_thumb.jpg" width="324" height="283" /></a>
<p>输入blogjava的主页地址<font style="background-color: #cce8cf"><a href="http://www.blogjava.net/">http://www.blogjava.net</font>/</a>，和你的账号密码等（hankchen是我的账号）。点击&#8220;下一步&#8221;：
<p><a href="http://www.blogjava.net/images/blogjava_net/hankchen/WindowsLiveWriter/WindowsLiveWriterblogjava_A167/clip_image006_2.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="clip_image006" src="http://www.blogjava.net/images/blogjava_net/hankchen/WindowsLiveWriter/WindowsLiveWriterblogjava_A167/clip_image006_thumb.jpg" width="326" height="282" /></a>
<p>这时候，到了关键的地方，需要你输入日志类型，和远程发布日志的URL，这些信息不是乱填的。博客园开放给Windows Live Writer的日志类型API为Customer MetaWeb，远程提交的<strong>API链接是：</strong>
<p><a href="http://yourname.blogjava.net/services/metaweblog.aspx">http://<em>yourname</em>.blogjava.net/services/metaweblog.aspx</a> <br />
<br />
例如：我的远程提交地址是<a href="http://yourname.blogjava.net/services/metaweblog.aspx">http://<em>hankchen</em>.blogjava.net/services/metaweblog.aspx</a><br />
<p>所以，填写内容如下：
<p><a href="http://www.blogjava.net/images/blogjava_net/hankchen/WindowsLiveWriter/WindowsLiveWriterblogjava_A167/clip_image008_2.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="clip_image008" src="http://www.blogjava.net/images/blogjava_net/hankchen/WindowsLiveWriter/WindowsLiveWriterblogjava_A167/clip_image008_thumb.jpg" width="316" height="276" /></a>
<p>点击下一步，会出现提示正在检查日志设置的操作，完成后出现：
<p><a href="http://www.blogjava.net/images/blogjava_net/hankchen/WindowsLiveWriter/WindowsLiveWriterblogjava_A167/clip_image010_2.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="clip_image010" src="http://www.blogjava.net/images/blogjava_net/hankchen/WindowsLiveWriter/WindowsLiveWriterblogjava_A167/clip_image010_thumb.jpg" width="306" height="266" /></a>
<p>点击&#8220;完成&#8221;按钮。恭喜你，设置完成！
<p>现在，点击&#8220;文件—打开&#8221;，就可以在客户端查看你的所有日志了：
<p><a href="http://www.blogjava.net/images/blogjava_net/hankchen/WindowsLiveWriter/WindowsLiveWriterblogjava_A167/clip_image012_2.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="clip_image012" src="http://www.blogjava.net/images/blogjava_net/hankchen/WindowsLiveWriter/WindowsLiveWriterblogjava_A167/clip_image012_thumb.jpg" width="300" height="235" /></a>
<p>接下来，就可以慢慢享受离线查看、编写blog日志的过程了！插入图片，表格什么的，一切就是这么简单。</p>
友情提示：本博文章欢迎转载，但请注明出处：<a href="http://www.blogjava.net/hankchen">陈新汉</a> <br />
<img src ="http://www.blogjava.net/hankchen/aggbug/295551.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hankchen/" target="_blank">hankchen</a> 2009-09-18 11:28 <a href="http://www.blogjava.net/hankchen/archive/2009/09/18/295551.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>