Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Effective Java ѧϰ±Ê¼Ç (7)

Finalizer ²»¿É¼Æ»®µÄ,Ò²ÊÇΣÏÕµÄ,Ò»°ãÒ²ÊDz»±ØÒªµÄ.
²»ÄÜÔÚfinalizerÖзÅÈκÎÓëÒÀÀµÊ±¼äÏà¹ØµÄ²Ù×÷,ÒòΪÄã²»ÖªµÀËüʲôʱºò±»Ö´ÐÐ. ±ÈÈçÔÚfinalizerÖйرÕÎļþµÄ×ö·¨¾ÍÊÇ´íÎóµÄ, ¸ù¾ÝJVMµÄʵÏÖ·½Ê½²»Í¬,ÓпÉÄܵ¼Ö´ò¿ªµÄÎļþÊý¹ý¶à¶øÎÞ·¨ÔÙ´ò¿ªÎļþ.
Ò²²»ÄÜÔÚfinalizerÖиıä״̬,Èç¸øÊý¾Ý¿â½âËøµÈ.
finalizer»¹ÄÜ´øÀ´ÑÏÖصÄÐÔÄÜÎÊÌâ,
ÏÔʾµÄµ÷ÓõÄÖÕÖ¹º¯Êý¿ÉÒÔ²ÉÓÃtry -finallyµÄÓï¾ä
µ±È»,ºÏ·¨µÄʹÓÃfinalizerÓÐÁ½ÖÖÇé¿ö:
Ò»ÖÖÊÇ×öΪ×îºóµÄÒ»µÀ¹Ø¿¨,¼ì²âÓû§ÊÇ·ñÓÐûÓб»ÊͷŵÄ×ÊÔ´,Èç¹ûÓÐÔòÊÍ·ÅËü,²¢´òÓ¡³ö¾¯¸æ. ËäÈ»²»ÌᳫÔÚfinalizerÖÐÊÍ·Å×ÊÔ´,µ«ÍíÊÍ·Å×ܱȲ»ÊͷźÃ(beter later than never)
»¹Ò»ÖֺϷ¨Ê¹ÓþÍÊÇÔÚʹÓà native·½·¨µÄʱºò.
ҪעÒâ,finallizerûÓгм̹Øϵ,ÔÚ×ÓÀàÖбØÐëÏÔʾµ÷Óø¸ÀàÖеĺ¯Êý.
±¾ÎÄÀ´×ÔCSDN²©¿Í£¬×ªÔØÇë±êÃ÷³ö´¦£ºhttp://blog.csdn.net/mutsinghua/archive/2010/01/23/5248540.aspx


Ïà¹ØÎĵµ£º

Java¶àÏ̱߳à³Ì¾­Ñé

²»¹ÜÎÒÊǶàôϲ»¶JAVAµ«ÊÇ£¬´Óʵ¼Ê¿ª·¢½Ç¶È½²£¬JavaµÄ¶àÏß³ÌȷʵûÓÐC++ºÃʹ¡£
±íÏÖÔÚ£º
1.JavaûÓÐÈ«¾Ö±äÁ¿£»
2.Java µÄÏß³ÌÖ®¼äµÄͨÐűȽϲC++ÌṩÁ˶àÖÖͨÐÅ·½Ê½£»
3.JavaµÄÊý¾Ýͬ²½ÊÇͨ¹ýsynchronizedÀ´ÊµÏÖ£¬µ«ÊÇ»ù±¾ÉϵÈÓÚ½»¸øÁËÐéÄâ»úÀ´Íê³É£¬¶øC++ÓкܶàÖÖ£ºÁÙ½çÇø¡¢»¥³âÌåµÈ¡£
4. JavaµÄ¶àÏß³Ìrun·½· ......

javaÕýÔò±í´ïʽ

package com.yzy;
import java.util.regex.*;
public class Test {
 /**
  * @param args
  */
 public static void main(String[] args) {
  Pattern p=Pattern.compile("^[a-z]+");
  Matcher m=p.matcher("a233"); //true
  //Matcher m=p.matcher("2233") ......

Java·´ÉäÖ®Methodµ÷ÓúÍFiledÉèÖÃ

·´ÉäÊÇjavaµÄÒ»¸ö¸ß¼¶ÌØÐÔ¡£
Reflection ÊÇJava±»ÊÓΪ¶¯Ì¬£¨»ò×¼¶¯Ì¬£©ÓïÑÔµÄÒ»¸ö¹Ø¼üÐÔÖÊ¡£Õâ¸ö»úÖÆÔÊÐí³ÌÐòÔÚÔËÐÐʱ͸¹ýReflection APIsÈ¡µÃÈκÎÒ»¸öÒÑÖªÃû³ÆµÄclassµÄÄÚ²¿ÐÅÏ¢£¬°üÀ¨Æämodifiers£¨ÖîÈçpublic, static µÈµÈ£©¡¢superclass£¨ÀýÈçObject£©¡¢ÊµÏÖÖ®interfaces£¨ÀýÈçSerializable£©£¬Ò²°üÀ¨fieldsºÍmethods µ ......

Effective Java ѧϰ±Ê¼Ç£¨3£©

ÔÚʵÏÖsingletonģʽʱ£¬ÎÒÃÇÓÐÒÔϼ¸ÖÖ·½·¨¡£
1. public static final ×ֶμÓÉÏprivate µÄ¹¹Ô캯Êý¡£
public class Singleton{
            public static final Singleton INSTANCE = new Singleton();
        & ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ