public class WeakReferenceMonitor extends Object
monitor(Object, ReleaseListener),
with the given handle object usually being a holder that uses the target
object underneath, and the release listener performing cleanup of the target
object once the handle is not strongly referenced anymore.
When a given handle becomes weakly reachable, the specified listener will be called by a background thread. This thread will only be started lazily and will be stopped once no handles are registered for monitoring anymore, to be restarted if further handles are added.
Thanks to Tomasz Wysocki for the suggestion and the original implementation of this class!
monitor(java.lang.Object, org.skfiy.util.WeakReferenceMonitor.ReleaseListener)| 限定符和类型 | 类和说明 |
|---|---|
static interface |
WeakReferenceMonitor.ReleaseListener
Listener that is notified when the handle is being released.
|
| 构造器和说明 |
|---|
WeakReferenceMonitor() |
public static void monitor(Object handle, WeakReferenceMonitor.ReleaseListener listener)
handle - the object that will be monitoredlistener - the listener that will be called upon release of the
handleCopyright © 2013 The Skfiy Open Association. All Rights Reserved.