hoares

分类

最新留言

链接

RSS

RSS Link
OGNL
Nimble

understanding weak reference

hoares posted @ 2012年10月26日 14:01 in 未分类 with tags java , 913 阅读

http://weblogs.java.net/blog/enicholas/archive/2006/05/understanding_w.html

Quoted from http://docs.oracle.com/javase/6/docs/api/java/lang/ref/package-summary.html

reference object encapsulates a reference to some other object so that the reference itself may be examined and manipulated like any other object. Three types of reference objects are provided, each weaker than the last: softweak, and phantom. Each type corresponds to a different level of reachability, as defined below. Soft references are for implementing memory-sensitive caches, weak references are for implementing canonicalizing mappings that do not prevent their keys (or values) from being reclaimed, and phantom references are for scheduling pre-mortem cleanup actions in a more flexible way than is possible with the Java finalization mechanism.

Reachability

Going from strongest to weakest, the different levels of reachability reflect the life cycle of an object. They are operationally defined as follows:

  • An object is strongly reachable if it can be reached by some thread without traversing any reference objects. A newly-created object is strongly reachable by the thread that created it.
  • An object is softly reachable if it is not strongly reachable but can be reached by traversing a soft reference.
  • An object is weakly reachable if it is neither strongly nor softly reachable but can be reached by traversing a weak reference. When the weak references to a weakly-reachable object are cleared, the object becomes eligible for finalization.
  • An object is phantom reachable if it is neither strongly, softly, nor weakly reachable, it has been finalized, and some phantom reference refers to it.
  • Finally, an object is unreachable, and therefore eligible for reclamation, when it is not reachable in any of the above ways.
Avatar_small
Ashton Draper 说:
2019年4月02日 14:57

When we will understand the wear points of own self then maximum things will be sort out from the actual part to have only. Finalization about those part of the partial depends on the best essay service review will about to deny from the reference prevent.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter