1<html> 2 <body> 3 <p> 4 Provides the system's {@link java.lang.ref.ReferenceQueue} implementation as well as 5 different forms of reference objects which impose special behavior on the 6 garbage collector. The behavior depends on the type of {@link java.lang.ref.Reference} 7 being used. Three different type of references exist, each being weaker 8 than the preceding one: {@link java.lang.ref.SoftReference}, {@link java.lang.ref.WeakReference}, and 9 {@link java.lang.ref.PhantomReference}. "Weakness" here means that less restrictions are 10 being imposed on the garbage collector as to when it is allowed to 11 actually garbage-collect the referenced object. 12 </p> 13 <p> 14 In order to use reference objects properly it is important to understand 15 the different types of reachability that trigger their clearing and 16 enqueueing. The following table lists these, from strongest to weakest. 17 For each row, an object is said to have the reachability on the left side 18 if (and only if) it fulfills all of the requirements on the right side. In 19 all rows, consider the <em>root set</em> to be a set of references that 20 are "resistant" to garbage collection (that is, running threads, method 21 parameters, local variables, static fields and the like). 22 </p> 23 <p> 24 <a name="definitions"></a> 25 <table> 26 <tr> 27 <td> 28 Strongly reachable 29 </td> 30 <td> 31 <ul> 32 <li> 33 There exists at least one path from the root set to the object 34 that does not traverse any instance of a {@link java.lang.ref.Reference} 35 subclass. 36 </li> 37 </ul> 38 </td> 39 </tr> 40 41 <tr> 42 <td> 43 Softly reachable 44 </td> 45 <td> 46 <ul> 47 <li> 48 The object is not strongly reachable. 49 </li> 50 <li> 51 There exists at least one path from the root set to the object 52 that does traverse a {@link java.lang.ref.SoftReference} instance, but no 53 {@link java.lang.ref.WeakReference} or {@link java.lang.ref.PhantomReference} instances. 54 </li> 55 </ul> 56 </td> 57 </tr> 58 59 <tr> 60 <td> 61 Weakly reachable 62 </td> 63 <td> 64 <ul> 65 <li> 66 The object is neither strongly nor softly reachable. 67 </li> 68 <li> 69 There exists at least one path from the root set to the object 70 that does traverse a {@link java.lang.ref.WeakReference} instance, but no 71 {@link java.lang.ref.PhantomReference} instances. 72 </li> 73 </ul> 74 </td> 75 </tr> 76 77 <tr> 78 <td> 79 Phantom-reachable 80 </td> 81 <td> 82 <ul> 83 <li> 84 The object is neither strongly, softly nor weakly reachable. 85 </li> 86 <li> 87 The object is referenced by a {@link java.lang.ref.PhantomReference} instance. 88 </li> 89 <li> 90 The object has already been finalized. 91 </li> 92 </ul> 93 </td> 94 </tr> 95 </table> 96 </p> 97 </body> 98</html> 99