Performance of Java code written guidelines for efficient

2011-04-29  来源:本站原创  分类:Java  人气:74 

  1. Whenever possible, use the basic variable types, instead of using the object type. For example, use int, instead of Integer.
  2. Cache frequently used short life that the object again and again to avoid the reconstruction of the same object, and therefore the GC.
  3. Through the string, use StringBuffer instead of string concatenation, because the string object has an immutable characteristic, and the need to create extra string objects, these objects must undergo the final GC.
  4. Avoid over-writing on the Java console, reducing the string object processing, text formatting and output of the cost.
  5. Implement database connection pooling and reuse connection object, rather than repeatedly opening and closing the connection.
  6. Using the thread pool (thread pooling). Avoid constantly create and delete the thread object, especially when in heavy use of threads.
  7. Through the System.gc () call in the code to avoid calling GC. GC is a "stop all treatment (stop the world)" in the event, which means that in addition to its GC thread, other threads are all running in a suspended state. If you must call the GC, you can idle in non-emergency phase or phases to achieve it.
  8. Allocation in the loop to avoid the object, which object in the Java heap will survive longer than necessary for survival.
相关文章
  • Performance of Java code written guidelines for efficient 2011-04-29

    Whenever possible, use the basic variable types, instead of using the object type. For example, use int, instead of Integer. Cache frequently used short life that the object again and again to avoid the reconstruction of the same object, and therefor

  • JAVA code written in 30 proposals recommended 2010-05-15

    JAVA code written in 30 proposals recommended (1) the class name the first word should be capitalized. Fields, methods, and object (handle) the first letter should be lowercase. For all identifiers, which contains all of the words should be close tog

  • Development skills: how easy it is to improve the performance of Java code 2011-04-26

    [Abstract] tail recursion transformation can speed up the application's speed, but not all of the JVM will do this conversion, many algorithms that will use tail recursion method is especially simple. Compiler will automatically convert into circulat

  • Configured in context.xml made the connection pool of Java code written 2010-08-18

    7. Bind (String name, Object obj) He is equivalent to the jndi factory, he hides the details of the product created, use the time I get on it directly. 8. Ctx.lookup ("jdbc / drp"); you can not get away with ah that was in front and a string, th

  • Agile Development of Java code to write high-quality 2009-12-24

    Agile development concept has been popular for a very long time, the development of agile development iteration stage, we can through the five steps to effectively improve the quality of the entire project code. Java project development process, due

  • [Change] agile development of high-quality Java code to write 2009-09-29

    Agile development concept has been popular for a very long time, the development of agile development iteration stage, we can through the five steps to effectively improve the quality of the entire project code. Java project development process, due

  • java code programming optimization 2010-03-26

    Procedures for the use of available resources (memory, CPU time, network bandwidth, etc.) is limited, the purpose of optimization is to allow programs to use the least resources to complete the scheduled tasks. Optimization usually contains two aspec

  • ttserver install + ttserver start and stop script (double standby) + java code 2010-09-02

    by: alex 1, download tokyocabinet-1.4.46.tar.gz Download tokyotyrant-1.1.41.tar.gz To select the local connection can download tokyocabinet-java-1.22.tar.gz Detailed installation documentation http://www.162cm.com/p/tokyotyrant.html 2, extracted into

  • Your java code safe? 2010-11-14

    In the development of Java Web applications, you need to ensure that the application has improved security features to add. Speaking of Java security here, we are not talking about the security provided by Java language API, not involving the use of

  • ttserver installation + ttserver start-stop script (double standby) + java code 2010-09-02

    by: alex 1, download tokyocabinet-1.4.46.tar.gz Download tokyotyrant-1.1.41.tar.gz You can choose to download local connection tokyocabinet-java-1.22.tar.gz Detailed installation documentation http://www.162cm.com/p/tokyotyrant.html 2, unzip into the

  • Agile Java code to write high-quality 2010-03-10

    Source: IBM dW / Wang Yongkui | De idea of agile development has been popular for a long time in Agile Development Kaifa iteration stage, we can through the five steps to effectively improve the entire project code quality. Java project development p

  • Java code optimization, strategies and methods 2010-05-04

    Java code optimization, strategies and methods - Summary 1. How to Use Exception Exception decrease performance. An exception thrown first need to create a new object. Throwable interface, the constructor call, called fillInStackTrace () local method

  • Agile developers to write Java code quality 2010-07-20

    The concept of agile development has been popular for a very long time, in the agile development iterations in the development stage, we can through the five steps to effectively improve the quality of the entire project code. Java project developmen

  • Review Java code, 11 kinds of common errors 2010-09-05

    Bug code review is to eliminate one of the most important ways, these reviews are particularly effective in most of the time. As the code review itself targeted, is overlooking the entire code in the testing process problems and Bug. Also, the code r

  • Java programs written thirty basic rules 2010-12-31

    Java programs written thirty basic rules (1) the class name first letter should be capitalized. Fields, methods, and object (handle) of the first letter should be lowercase. For all identifiers, which contains all the words should be close together,

  • Java language coding standards (Java Code Conventions 2009-01-05

    At the beginning of Notes ") http://www.huihoo.org/code/java_code_conventions.html - Package and the introduction of statements (see "package and the introduction of statements") - Class and interface declarations (see "classes and int

  • Eclipse developers can use LoadRunner to run the Java code 2010-02-05

    Java developers using the LoadRunner testing, and if we can directly use the Java programs written test, then, will feel very comfortable. The native LoadRunner Java language itself, the editor is very unfriendly to use, if we can edit the Java code

  • How can we improve the performance of JAVA? 2010-04-16

    Improve the performance of JAVA, generally consider the following four main areas: (1) programming methods and models of a good design can improve the performance of procedures, this applies not only to JAVA, also applies to any programming language.

  • ORACLE statements in Java code to perform insert operation error: ORA-00911: invalid character 2010-05-12

    For insert operations sql: INSERT INTO FB10_COLLIGATE_SATAISTIC (colligate_statistic_id, inner_code, report_date) VALUES (COLLIGATE_STATISTIC_ID_SEQ.NEXTVAL, #innerCode#, #reportDate#); Problem description: sql is simple to insert data into a table a

  • dynamically compiled java code problem 2010-10-29

    After listening to one on the back of dynamic compilation and static on the Java compiled classes, feel that they do not know much in this respect, then finishing the next knowledge points, but also check the internet for some information on Java, dy