下载此文档

java技巧精炼(java技巧精炼).doc


文档分类:IT计算机 | 页数:约24页 举报非法文档有奖
1/24
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/24 下载此文档
文档列表 文档介绍
java技巧精炼(java技巧精炼).docjava技巧精炼(java技巧精炼)
First, general articles
The problem discussed in the general chapter is suitable for most Java applications.
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) ();
}
The above idea is also useful for array processing.
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 introduces a non blocking I/O Library (). 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".
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

java技巧精炼(java技巧精炼) 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数24
  • 收藏数0 收藏
  • 顶次数0
  • 上传人xinsheng2008
  • 文件大小32 KB
  • 时间2018-07-31
最近更新