common_helper/src/main/java/com/xiongyingqi/util/WeakReferenceMonitor.java
public static void monitor(Object handle, ReleaseListener listener) {
        if (logger.isDebugEnabled()) {
            logger.debug("Monitoring handle [" + handle + "] with release listener [" + listener + "]");
        }

        // Make weak reference to this handle, so we can say when
        // handle is not used any more by polling on handleQueue.
        WeakReference<Object> weakRef = new WeakReference<Object>(handle, handleQueue);

        // Add monitored entry to internal map of all monitored entries.
        addEntry(weakRef, listener);
    }
public static void monitor(Object handle, ReleaseListener listener) {
        if (logger.isDebugEnabled()) {
            logger.debug("Monitoring handle [" + handle + "] with release listener [" + listener + "]");
        }

        // Make weak reference to this handle, so we can say when
        // handle is not used any more by polling on handleQueue.
        WeakReference<Object> weakRef = new WeakReference<Object>(handle, handleQueue);

        // Add monitored entry to internal map of all monitored entries.
        addEntry(weakRef, listener);
    }
Start to monitor given handle object for becoming weakly reachable.
When the handle isn't used anymore, the given listener will be called.

@param handle   the object that will be monitored
@param listener the listener that will be called upon release of the handle