weakhashmap

weakhashmapweakhashmap
  1. Using WeakHashMap solves the problem of Thread objects not getting garbage collected , at some additional performance cost .

    以一些额外的性能开销为代价,使用WeakHashMap解决了无法对Thread对象进行垃圾回收的问题。

  2. The implementation of WeakHashMap illustrates a common idiom with weak references & that some internal object extends WeakReference .

    WeakHashMap的实现展示了弱引用的一种常见用法&一些内部对象扩展WeakReference。

  3. When you add a mapping to a WeakHashMap , remember that it is possible that the mapping could " fall out " later because the key is garbage collected .

    在向WeakHashMap中添加映射时,请记住映射可能会在以后“脱离”,因为键被垃圾收集了。

  4. WeakHashMap has a private method called expungeStaleEntries () that is called during most Map operations , which polls the reference queue for any expired references and removes the associated mappings .

    WeakHashMap有一个名为expungeStaleEntries()的私有方法,大多数Map操作中会调用它,它去掉引用队列中所有失效的引用,并删除关联的映射。

  5. Because this is such a common use for weak references , WeakHashMap , which uses weak references for keys ( but not for values ), was also added to the class library in JDK1.2 .

    因为这是弱引用最常见的用法,WeakHashMap也被添加到JDK1.2的类库中,它对键(而不是对值)使用弱引用。