<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    神奇好望角 The Magical Cape of Good Hope

    庸人不必自擾,智者何需千慮?
    posts - 26, comments - 50, trackbacks - 0, articles - 11
      BlogJava :: 首頁 ::  :: 聯系 :: 聚合  :: 管理

    Java 中對象引用的類型

    Posted on 2007-12-02 20:43 蜀山兆孨龘 閱讀(1263) 評論(0)  編輯  收藏
    Java 中對象引用的類型 Object Reference Types in Java
      弱引用早有耳聞,但從來沒去認真看過。前天改編陳維雷先生的下雪動畫時,發現他使用了弱引用,于是趁機把 Java 的對象引用類型看了個究竟。     I've heard of weak reference for a long time, but have never study it seriously yet. The day before yesterday, when I was modifying Mr. William Chen's snowing animation, I saw weak reference was utilized, and then took the chance to read the details of Java's reference type.
      除了通常意義下的強引用,包 java.lang.ref 還定義了其他三種平時不太用到的引用:軟引用、弱引用和虛引用,但 API 文檔的解釋比較含糊。我在網上搜到了一些資料,簡單歸納一下。     Except the strong reference of common purpose, package java.lang.ref defines three other references which are less often used: soft reference, weak reference and phantom reference, but they have obscure explanations in the API documention. I searched online and got some stuffs and here are my summaries.
      強引用。當一個對象具有強引用時,Java 虛擬機寧愿拋出 OutOfMemeryError,也絕不讓垃圾回收器回收它。     Strong Reference. When an object holds strong references, Java Virtue Machine would rather throw an OutOfMemeryError than let garbage collector (GC) collect it.
      軟引用。當一個對象只具有軟引用時,垃圾回收器只在內存不足的時候才回收它。     Soft Reference. When an object holds only soft references, GC collects it only if there is not enough memory.
      弱引用。當一個對象只具有弱引用時,一旦被垃圾回收器發現就會被回收。因為垃圾回收器是一個優先級很低的線程,所以弱引用對象也不一定會馬上就會被回收。     Weak Reference. When an object holds only weak references, GC collects it as soon as finds it. GC is a thread of very low priority, so a weak reference object may not be collected immediately.
      虛引用。虛引用和對象的生命周期無關。虛引用必須和引用隊列聯合使用,對象將被回收前,其虛引用將被加入到引用隊列。虛引用只是用來監視對象的回收。     Phantom Reference. Phantom reference has nothing to do with the life cycle of an object. Phantom reference must be used together with reference queue, and the object's phantom reference will be added into that reference queue right before collected. Phantom reference is only used to monitor object collecting.
      從以上是否能看出,一個對象不能同時具有軟引用和弱引用?     From above shall we say that an object can't have a soft reference and a weak reference at the same time?

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲色图视频在线观看| 亚洲无码高清在线观看| 亚洲日本在线观看网址| 久久99热精品免费观看牛牛| 亚洲日韩精品射精日| 国产成人免费ā片在线观看老同学 | 国产乱子影视频上线免费观看| 波多野结衣亚洲一级| 国产香蕉九九久久精品免费| 中文字幕亚洲精品无码| 日本免费无遮挡吸乳视频电影| 亚洲av日韩精品久久久久久a| 亚洲AⅤ优女AV综合久久久| 人人爽人人爽人人片A免费| 亚洲欧洲日产国码av系列天堂| 久久久国产精品福利免费| 久久久久亚洲Av无码专| 91嫩草国产在线观看免费| 亚洲色大成网站www永久网站| 热久久精品免费视频| 一区二区3区免费视频| 午夜亚洲国产理论秋霞| 免费在线看v网址| 在线观看亚洲免费视频| 亚洲精品乱码久久久久久蜜桃不卡 | 免费人成年激情视频在线观看 | 久久精品国产精品亚洲| 免费日本一区二区| 亚洲中文字幕在线无码一区二区| 全免费一级毛片在线播放| 日韩一级片免费观看| 亚洲成色999久久网站| 女人与禽交视频免费看| 国产成人无码精品久久久免费| 亚洲成a人片在线观看中文动漫| 国产乱码免费卡1卡二卡3卡| 国产亚洲福利一区二区免费看| 亚洲乱码一区二区三区在线观看| 国产又大又粗又长免费视频 | 全部在线播放免费毛片| 亚洲成人动漫在线|