文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>[Java] Reference Object

[Java] Reference Object

时间:2010-09-13  来源:web_surf

  1. Documents
    • http://www.ibm.com/developerworks/library/j-refs/
    • http://www.cnblogs.com/abob/archive/2009/10/27/1590711.html
    • http://download-llnw.oracle.com/javase/1.3/docs/api/java/lang/ref/package-summary.html
  2. Package
    java.lang.ref
  3. Objective
    If you want to refer to some objects without preventing VM to collect them, you can use reference object. For example, in the statement "String obj = new String("data");", GC will not collect obj unless it goes out of scope or it is assigned to null; but if you use reference object as following:
        String obj = new ("data");
        WeakReference ref = new WeakReference(obj); //Create a reference to obj, the reference doesn't prevent VM to collect obj
        obj = null; //Inform GC to collect obj at some time
        if (ref.get() == null)  //You can refer to obj with ref, but first of  all, you must check if obj is collected
        {
            System.out.println("obj is not collected");
        }
        else
        {
            System.out.println("obj is collected");
        }

    There are 3 types of reference:
    • PhantomReference
    • WeakReference
    • SoftReference
  4. xxx
相关阅读 更多 +
排行榜 更多 +
空中跑酷汉化版

空中跑酷汉化版

赛车竞速 下载
修仙传说

修仙传说

角色扮演 下载
魔界零之迷宫

魔界零之迷宫

冒险解谜 下载