- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
java技巧精炼(java技巧精炼).doc
java技巧精炼(java技巧精炼)
First, general articles
The problem discussed in the general chapter is suitable for most Java applications.
1.1 create instances of classes without new keywords
When you create an instance of a class with new keyword, all constructors in the constructor chain are automatically invoked. But if an object implements the Cloneable interface, we can call its clone () method. The clone () method does not call any class constructor.
In the case of using design patterns (Design Pattern), if you create objects in Factory mode, it is very simple to create new object instances by using clone () method. For example, here is a typical implementation of the Factory schema:
Public static Credit getNewCredit () {
Return new Credit ();
}
The improved code uses the clone () method, as shown below:
Private static Credit BaseCredit = new Credit ();
Public static Credit getNewCredit () {
Return (Credit) BaseCredit.clone ();
}
The above idea is also useful for array processing.
1.2 use non blocking I/O
The lower version of JDK does not support non blocking I/O API. In order to avoid I/O congestion, some applications use the method of creating large threads (in a better case, using a buffer pool). This technology can be seen in many applications that must support concurrent I/O flows, such as Web servers, pricing and auction applications. However, creating Java threads requires considerable overhead.
JDK 1.4 introduces a non blocking I/O Library (java.nio). If the application requires an earlier version of JDK, there is a software package that supports non blocking I/O.
Please refer to Sun China website for adjusting Java performance of I/O.
1.3 careful use of exceptions
Exceptions are bad for performance. To throw an exception, you first create a new object. The constructor of the Throwable interface calls the local (Native) method named fillInStackTrace (), and the fillInStackTrace () method checks the stack and collects call tracing information. As long as the excep
您可能关注的文档
- 风湿性疾病贫血免疫学发病机制初探——附例临床分析.doc
- 英语专业四级考试-年完型和语词选择.doc
- -公文写作范例-通报.doc
- 企业并购律师实务——要约收购报告书的制作.doc
- 高职设计类专业素描课程重构的思路与实践.doc
- 原来是美男啊 分集剧情介绍(It was a beauty, diversity story introduced).doc
- 学习方法新目标八年级英语上册个单元重点知识必备_英语.doc
- _《探究感应电流的产生条件》教案设计.doc
- 王守仁主编_高职高专实用综合教程unit-教案.doc
- 分镜头画面(Shot picture).doc
- 2017年山东省卫生系统“六五”普法考试题库(二类)带答案(已排版整理)90-17.doc
- 高考满分作文【精华版】 (字).doc
- 2013高考化学高三复习专题30分钟自测题集(25专题汇编 解析版).docx
- 2014年全国硕士研究生入学统一考试英语试题及答案解析.doc
- 英语词汇分类影视英语词汇(Classification of English words film English Vocabulary).doc
- 2016年会计专业中级技术资格考试经济法模拟试题.doc
- 《汇编语言、微机原理及接口技术(第版)》郑初华_课后题解答.doc
- 2016年中级经济师建筑专业知识与实务讲义第六章 工程建设项目招标投标.doc
- 电影帕丁顿熊2Paddington.2.2017台词剧本中英文对照完整版.docx
- 邓丽君黑白照成彩张.docx
文档评论(0)