當沒有使用JIT或Hotspot虛擬機時,盡量使用0值作為終結條件的比較元素,以提高循環語句的性能。
零值比較
今天看了一博文介紹Java線程安全方面的,好像和之前看過的一本書Java Concurrency in Practice中的內容差不多。努力學習消化之。
注意:
那么大家肯定會想,在方法中加同步關鍵字和在方法里面分解出耗時且不影響類狀態的改變的同步代碼塊,這兩個解決方案如何選擇呢?
那么必須要編程者清晰的知道類中的變量和競爭條件。所以編程者要切記在方法中添加關鍵字,雖然簡單但是會影響并發性能,特別是在方法里面含有耗時的操作,如:I/O,網絡連接、等等。
Use the Apache Ant tool to create these files. Apache Ant is a Java-based build tool that enables you to generate XML-based configurations files as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<project default="build">
<dirname property="basedir" file="${ant.file}"/>
<property name="beanname" value="SimpleBean"/>
<property name="jarfile" value="${basedir}/${beanname}.jar"/>
<target name="build" depends="compile">
<jar destfile="${jarfile}" basedir="${basedir}" includes="*.class">
<manifest>
<section name="${beanname}.class">
<attribute name="Java-Bean" value="true"/>
</section>
</manifest>
</jar>
</target>
<target name="compile">
<javac destdir="${basedir}">
<src location="${basedir}"/>
</javac>
</target>
<target name="clean">
<delete file="${jarfile}">
<fileset dir="${basedir}" includes="*.class"/>
</delete>
</target>
</project>